Advertisement
Guest User

Roblox gun script

a guest
Dec 22nd, 2019
14,325
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. local tool = script.Parent
  2. local player = game.Players.LocalPlayer
  3. local character = player.Character
  4. local mouse = player:GetMouse()
  5. local reloading = false
  6. local difference = 0
  7. local replicatedstorage = game:GetService("ReplicatedStorage")
  8. --local gungui = tool:WaitForChild("GunGUI")
  9. local bullets = tool:WaitForChild("Bullets")
  10. local reloadtime = 3
  11. --Reloading:
  12. function reload()
  13.     reloading = true
  14.     mouse.Icon = "http://www.roblox.com/asset?id=936489163"
  15.     --player.PlayerGui:WaitForChild("GunGUI").Bullets.Text = "Reloading!"
  16.     wait(2.5)
  17.     bullets.Value = 6   --BEWARE OF THIS (it was originally adding 6 to bullets.Value .It got changed cuz it added too many bullets.)
  18.     --player.PlayerGui:WaitForChild("GunGUI").Bullets.Text = "Bullets: "..bullets.Value
  19.     mouse.Icon = "http://www.roblox.com/asset?id=936803874"
  20.     --equipAnimation:FireServer(tool.shoot)
  21.     reloading = false
  22. end
  23. tool.Equipped:Connect(function(mouse)
  24.     --gungui:Clone().Parent = player.PlayerGui -- We are cloning the Gun GUI into the player's PlayerGUI
  25.     --findBodyType() -- Calling the function above to check the body type.
  26.     --equipAnimation:FireServer(tool.shoot) -- Calling the equip animation remoteevent so that the server can play the animation
  27.     mouse.Icon = "http://www.roblox.com/asset?id=936803874"
  28.     mouse.Button1Down:Connect(function()
  29.         if reloading == false then
  30.             if bullets.Value > 0 then
  31.                 print("shoot working")
  32.                 bullets.Value = bullets.Value - 1
  33.             else
  34.                 print("reload working")
  35.                 reload()
  36.                 print("Bullets: ")
  37.                 print(bullets.Value)
  38.             end
  39.         end
  40.     end)
  41.     tool.Unequipped:Connect(function()
  42.     mouse.Icon = ""
  43.     --unequipanimation:FireServer(tool.shoot)
  44.     --player.PlayerGui.GunGUI:Destroy()
  45.     --contextActionService:UnbindAction("ReloadBtn")
  46.     end)
  47.    
  48. end)
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement