Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A LocalScript in a tool in startergui
- script.Parent.Equipped:connect(function()
- local event = game.ServerStorage:WaitForChild("Events").Gun.AmmoGui.AmmoOpen
- event:FireServer()
- print("Sent!")
- end)
- script.Parent.Unequipped:connect(function()
- local event = game.ServerStorage:WaitForChild("Events").Gun.AmmoGui.AmmoOpen
- event:FireServer()
- print("Sent!")
- end)
- script.Parent.Activated:connect(function()
- local event = game.ServerStorage:WaitForChild("Events").Gun.Main.Shoot
- event:FireServer()
- print("Sent!")
- end)
- The server script in replicatedstorage
- local e = game.ServerStorage:WaitForChild("Events").Gun.Main.Shoot
- e.OnServerEvent:connect(function(plr)
- print("Recieved!")
- local Gun = plr.Backpack.Gun
- local mouse = plr:GetMouse()
- local Ammo = Gun.Ammo
- local bullet = Instance.new("Part",game.workspace)
- bullet.Shape = "Ball"
- bullet.Size = Vector3.new(0.5,0.5,0.5)
- bullet.TopSurface = "Smooth"
- bullet.BottomSurface = "Smooth"
- bullet.BrickColor = BrickColor.new("Really Black")
- bullet.CanCollide = false
- bullet.Anchored = false
- bullet.Name = "Bullet"
- --CFrame Stuff
- bullet.CFrame = Gun.Handle.CFrame
- bullet.CFrame = CFrame.new(bullet.Position,mouse.Hit.p)
- --body velocity
- local v = Instance.new("BodyVelocity",bullet)
- v.velocity = bullet.CFrame.lookVector * 90
- v.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
- game.Debris:AddItem(bullet, 5)
- Ammo.Value = Ammo.Value - 1
- if Ammo.Value <= 0 then
- repeat
- Ammo.Value = Ammo.Value + 1
- wait(0.3)
- until Ammo.Value == 40
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment