Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. wait(2)
  2. local tool = script.Parent
  3. local player = game:GetService("Players").LocalPlayer
  4. local gunshotevent = game.ReplicatedStorage.Gunshot
  5. local settings = tool.Settings
  6. local gui = player.PlayerGui.MainGUI
  7.  
  8. --Load the gun stats
  9. local damage = settings.Damage.Value
  10. local magsize = settings.MagSize.Value
  11. local debouncetime = settings.DebounceTime.Value
  12. local reloadtime = settings.ReloadTime.Value
  13. local range = settings.Range.Value
  14. local mags = settings.Mags.Value
  15.  
  16. local debounce = false
  17. local mag = magsize
  18. local reloaddebounce = false
  19.  
  20. gui.InGame.WeaponName.Text = tool.Name
  21. gui.InGame.AmmoAmount.Text = mag.."/"..(mags*magsize)
  22.  
  23. tool.Equipped:connect(function(mouse)
  24. settings:Destroy()
  25.  
  26. mouse.Button1Down:connect(function()
  27. if debounce == false and mag > 0 then
  28. local hit = mouse.Hit.p
  29. local muzzle = script.Parent.Muzzle
  30. gunshotevent:FireServer(hit, muzzle, damage, range)
  31. debounce = true
  32. mag = mag - 1
  33. gui.InGame.WeaponName.Text = tool.Name
  34. gui.InGame.AmmoAmount.Text = mag.."/"..(mags*magsize)
  35. wait(debouncetime)
  36. debounce = false
  37. tool.Handle.Fire:Play()
  38. local anim1 = player.Character.Humanoid:LoadAnimation(tool.Handle.FireAnim)
  39. anim1:Play()
  40. else
  41. if mag == 0 and mags > 0 and reloaddebounce == false then
  42. reloaddebounce = true
  43. gui.InGame.AmmoAmount.Text = "Reloading"
  44. tool.Handle.Reload:Play()
  45. local anim = player.Character.Humanoid:LoadAnimation(tool.Handle.ReloadAnim)
  46. anim:Play()
  47. wait(reloadtime)
  48. mag = magsize
  49. mags = mags - 1
  50. gui.InGame.WeaponName.Text = tool.Name
  51. gui.InGame.AmmoAmount.Text = mag.."/"..(mags*magsize)
  52. reloaddebounce = false
  53. end
  54. end
  55. end)
  56. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement