Advertisement
Guest User

Untitled

a guest
Dec 24th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. game:GetService("UserInputService").InputBegan:Connect(function(inputobject, gameprocessedEvent)
  2. if inputobject.KeyCode == Enum.KeyCode.R then
  3. if script.Parent.TotalAmmo.Value <= 0 then
  4. while true do
  5. wait(999999999)
  6. end
  7. end
  8. if script.Parent.TakenOut.Value == true and script.Parent.Ammo.Value < 20 and script.Parent.Reloading.Value == false and script.Parent.Shooting.Value == false then
  9. script.Parent.Reloading.Value = true
  10. local ammo = Instance.new("Part", game.Workspace)
  11. ammo.CFrame = CFrame.new(script.Parent.Handle.Position)
  12. ammo.BrickColor = script.Parent.Handle.BrickColor
  13. ammo.CanCollide = true
  14. ammo.TopSurface = ("Smooth")
  15. ammo.BottomSurface = ("Smooth")
  16. ammo.Size = Vector3.new(0.2,1,0.2)
  17. ammo.Name = ("Ammo")
  18. local gui = game.Players.LocalPlayer.PlayerGui.GunThing
  19. local amountofammo = 20 - script.Parent.Ammo.Value
  20. for a = 3, 0, -1 do
  21. gui.Ammo.Text = ("Reloading... (" .. a .. ")")
  22. wait(1)
  23. end
  24. script.Parent.Reloading.Value = false
  25. if script.Parent.TotalAmmo.Value - amountofammo <= 0 then
  26. if amountofammo + script.Parent.Ammo.Value <= 20 then
  27. script.Parent.Ammo.Value = script.Parent.Ammo.Value + script.Parent.TotalAmmo.Value
  28. script.Parent.TotalAmmo.Value = 0
  29. end
  30. else
  31. script.Parent.TotalAmmo.Value = script.Parent.TotalAmmo.Value - amountofammo
  32. script.Parent.Ammo.Value = 20
  33. end
  34.  
  35. gui.Ammo.Text = ("Ammo: " .. script.Parent.Ammo.Value .. " / " .. script.Parent.TotalAmmo.Value)
  36. ammo.TextColor3 = Color3.new(255,255,255)
  37.  
  38. wait(1)
  39.  
  40. ammo:Destroy()
  41. end
  42. end
  43. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement