Guest User

Untitled

a guest
Feb 5th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. A LocalScript in a tool in startergui
  2. script.Parent.Equipped:connect(function()
  3.     local event = game.ServerStorage:WaitForChild("Events").Gun.AmmoGui.AmmoOpen
  4.     event:FireServer()
  5.     print("Sent!")
  6. end)
  7.  
  8. script.Parent.Unequipped:connect(function()
  9.     local event = game.ServerStorage:WaitForChild("Events").Gun.AmmoGui.AmmoOpen
  10.     event:FireServer()
  11.     print("Sent!")
  12. end)
  13.  
  14. script.Parent.Activated:connect(function()
  15.     local event = game.ServerStorage:WaitForChild("Events").Gun.Main.Shoot
  16.     event:FireServer()
  17.     print("Sent!")
  18. end)
  19.  
  20. The server script in replicatedstorage
  21.  
  22. local e = game.ServerStorage:WaitForChild("Events").Gun.Main.Shoot
  23. e.OnServerEvent:connect(function(plr)
  24.     print("Recieved!")
  25.     local Gun = plr.Backpack.Gun
  26.     local mouse = plr:GetMouse()
  27.     local Ammo = Gun.Ammo
  28.     local bullet = Instance.new("Part",game.workspace)
  29.     bullet.Shape = "Ball"
  30.     bullet.Size = Vector3.new(0.5,0.5,0.5)
  31.     bullet.TopSurface = "Smooth"
  32.     bullet.BottomSurface = "Smooth"
  33.     bullet.BrickColor = BrickColor.new("Really Black")
  34.     bullet.CanCollide = false
  35.     bullet.Anchored = false
  36.     bullet.Name = "Bullet"
  37.     --CFrame Stuff
  38.     bullet.CFrame = Gun.Handle.CFrame
  39.     bullet.CFrame = CFrame.new(bullet.Position,mouse.Hit.p)
  40.     --body velocity
  41.     local v = Instance.new("BodyVelocity",bullet)
  42.     v.velocity = bullet.CFrame.lookVector * 90
  43.     v.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  44.     game.Debris:AddItem(bullet, 5)
  45.     Ammo.Value = Ammo.Value - 1
  46.     if Ammo.Value <= 0 then
  47.         repeat
  48.             Ammo.Value = Ammo.Value + 1
  49.             wait(0.3)
  50.         until Ammo.Value == 40
  51.     end
  52. end)
Advertisement
Add Comment
Please, Sign In to add comment