So i am making a gun. Basically im working right now on reload stuff. its done but When it reloaded i can shoot forever without More reloading. Heres the script:
wait(3)
local Humanoid = game.Players.LocalPlayer.Character.Humanoid
local ShootAnimation = Instance.new("Animation")
local ReloadAnimation = Instance.new("Animation")
ReloadAnimation.AnimationId = "rbxassetid://5593968248"
local ReloadAnimationTrack = Humanoid:LoadAnimation(ReloadAnimation)
ShootAnimation.AnimationId = "rbxassetid://5593333395"
local ShootAnimationTrack = Humanoid:LoadAnimation(ShootAnimation)
bullets = 9
local mouse = game.Players.LocalPlayer:GetMouse()
local Handle = script.Parent.Handle
local Gun = script.Parent
ReloadAnimationTrack.Looped = false
function Reload() -- Somewhere on this function stuff?
print("Reloading...")
ReloadAnimationTrack:Play()
wait(ReloadAnimationTrack.Stopped)
return
end
warn('The Tool M9 Is Officialy made by HKprogram To Easyjet Security')
Gun.Activated:Connect(function()
if mouse.Target.Parent:FindFirstChild("Humanoid") then -- Clicked a type of humanoid
if bullets == 0 then
Reload()
end
bullets = bullets - 1 -- When you see this. Its Removing bullets
ShootAnimationTrack:Play()
mouse.Target.Parent.Humanoid:TakeDamage(30) -- Damage 50 taken
print("Target: "..mouse.Target.Name)
elseif mouse.Target.Parent:FindFirstChild("Head") then
if bullets == 0 then
Reload()
end
ShootAnimationTrack:Play()
mouse.Target.Parent.Humanoid:TakeDamage(100)
bullets = bullets - 1
print("Target: "..mouse.Target.Name)
else
if bullets == 0 then
Reload()
end
bullets = bullets - 1
ShootAnimationTrack:Play()
print("Target: "..mouse.Target.Name)
end
end)
Anyone know the problem? theres no errors in script

2 comments
@marinhren Im sorry for the bad method. i am Just Trying a bit with Other Ideas in my head. btw everything is not done yet
NO I AM STUPID I FORGOT THAT SORRY @marinhren