Advertisement
darkblooood

localscript

Jan 25th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. local tool = script.Parent
  2. local player = game:GetService("Players").LocalPlayer
  3. local mousedown = false
  4.  
  5. tool.Equipped:Connect(function(mouse)
  6. print("Tool equipped!")
  7.  
  8. local ammo = player.PlayerGui.AmmoGUI.Main.Ammo
  9. local name = player.PlayerGui.AmmoGUI.Main.GunName
  10. local main = player.PlayerGui.AmmoGUI
  11.  
  12. local holdAnim = Instance.new("Animation")
  13. holdAnim.AnimationId = "http://www.roblox.com/Asset?ID="..tool.Stats.AnimID.Value
  14.  
  15. local holdAnimTrack = player.Character.Humanoid:LoadAnimation(holdAnim)
  16. holdAnimTrack:Play()
  17.  
  18.  
  19.  
  20. main.Enabled = true
  21.  
  22. ammo.Text = tool.Stats.Ammo.Value .."/"..tool.Stats.MaxAmmo.Value
  23. name.Text = tool.Name
  24.  
  25. tool.Unequipped:Connect(function()
  26.  
  27. main.Enabled = false
  28. holdAnimTrack:Stop()
  29.  
  30. end)
  31.  
  32. tool.Stats.Ammo.Changed:Connect(function()
  33.  
  34. ammo.Text = tool.Stats.Ammo.Value .."/"..tool.Stats.MaxAmmo.Value
  35.  
  36. end)
  37.  
  38.  
  39.  
  40. mouse.Button1Down:Connect(function()
  41.  
  42. local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.ShootPart.CFrame.p).unit * 300)
  43. local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
  44.  
  45. script.Parent.Remotes.CreateRay:FireServer(part, position)
  46.  
  47. end)
  48.  
  49. end)
  50.  
  51. script.Parent:WaitForChild("Remotes").CreateRay.OnClientEvent:Connect(function(part, position)
  52.  
  53. local beam = Instance.new("Part", workspace.Rays)
  54.  
  55. beam.BrickColor = BrickColor.new("Bright yellow")
  56. beam.FormFactor = "Custom"
  57. beam.Material = "Neon"
  58. beam.Transparency = 0.25
  59. beam.Anchored = true
  60. beam.Locked = true
  61. beam.CanCollide = false
  62. beam.Name = "beam"
  63.  
  64. local distance = (tool.Handle.CFrame.p - position).magnitude
  65. beam.Size = Vector3.new(0.2, 0.2, distance)
  66.  
  67.  
  68.  
  69. beam.CFrame = CFrame.new(tool.ShootPart.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
  70.  
  71. game["Run Service"].Heartbeat:Connect(function()
  72.  
  73. beam.Transparency = beam.Transparency + 0.05
  74.  
  75. end)
  76.  
  77. game:GetService("Debris"):AddItem(beam, 0.5)
  78.  
  79. if part then
  80.  
  81. if part.Parent then
  82.  
  83. local humanoid = part.Parent:FindFirstChild("Humanoid")
  84.  
  85. if not humanoid then
  86. humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
  87. end
  88.  
  89. if humanoid then
  90. script.Parent.Remotes.Damage:FireServer(humanoid)
  91. end
  92.  
  93. end
  94.  
  95. end
  96.  
  97. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement