Advertisement
FragRage21

Gun Script

Feb 19th, 2019
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. --Client Side
  2. local plr = game.Players.LocalPlayer
  3. local mouse = plr:GetMouse()
  4. local tool = script.Parent
  5. script.Parent.Activated:Connect(function()
  6. tool.Event1:FireServer(mouse)
  7. end)
  8. --Server Side
  9. local tool = script.Parent
  10. d = false
  11. local shoot = tool.Handle.GunShot
  12. local ting = tool.Handle.BulletTing
  13. local reload = tool.Handle.GunReload
  14. tool.Event1.OnServerEvent:Connect(function(plr,mouse)
  15. shoot:Play()
  16. local b = Instance.new("Part",workspace)
  17. local v = Instance.new("BodyVelocity",b)
  18. b.Size = Vector3.new(.1,.1,.5)
  19. b.BrickColor = BrickColor.new("Bright yellow")
  20. b.Material = "Neon"
  21. local ray = Ray.new(tool.Handle.CFrame.p,(mouse.Hit.p - tool.Handle.CFrame.p).unit)
  22. local part,position = workspace:FindPartOnRay(ray, plr.Character,true,true)
  23. b.CFrame = CFrame.new(tool.Handle.CFrame.p,position)
  24. v.Velocity = (b.CFrame.LookVector) * 500
  25. game.Debris:AddItem(b,5)
  26. part.Touched:Connect(function(p)
  27. if not d and p.Parent.Name ~= plr.Name and p.CanCollide == true then
  28.  d = true
  29.  if p.Parent:FindFirstChild("Humanoid") then
  30.   p.Parent.Humanoid:TakeDamage(10)
  31.   end
  32.  b:Destroy()
  33.  wait()
  34.  d = false
  35.  end
  36. end)
  37. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement