Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- game:GetService("UserInputService").InputBegan:Connect(function(inputobject, gameprocessedEvent)
- if inputobject.KeyCode == Enum.KeyCode.R then
- if script.Parent.TotalAmmo.Value <= 0 then
- while true do
- wait(999999999)
- end
- end
- 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
- script.Parent.Reloading.Value = true
- local ammo = Instance.new("Part", game.Workspace)
- ammo.CFrame = CFrame.new(script.Parent.Handle.Position)
- ammo.BrickColor = script.Parent.Handle.BrickColor
- ammo.CanCollide = true
- ammo.TopSurface = ("Smooth")
- ammo.BottomSurface = ("Smooth")
- ammo.Size = Vector3.new(0.2,1,0.2)
- ammo.Name = ("Ammo")
- local gui = game.Players.LocalPlayer.PlayerGui.GunThing
- local amountofammo = 20 - script.Parent.Ammo.Value
- for a = 3, 0, -1 do
- gui.Ammo.Text = ("Reloading... (" .. a .. ")")
- wait(1)
- end
- script.Parent.Reloading.Value = false
- if script.Parent.TotalAmmo.Value - amountofammo <= 0 then
- if amountofammo + script.Parent.Ammo.Value <= 20 then
- script.Parent.Ammo.Value = script.Parent.Ammo.Value + script.Parent.TotalAmmo.Value
- script.Parent.TotalAmmo.Value = 0
- end
- else
- script.Parent.TotalAmmo.Value = script.Parent.TotalAmmo.Value - amountofammo
- script.Parent.Ammo.Value = 20
- end
- gui.Ammo.Text = ("Ammo: " .. script.Parent.Ammo.Value .. " / " .. script.Parent.TotalAmmo.Value)
- ammo.TextColor3 = Color3.new(255,255,255)
- wait(1)
- ammo:Destroy()
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement