local Flourbag = game.Workspace.Flourbag["Bag(Top)"]
local clickDec = game.Workspace.Flourbag["Bag(Top)"].ClickDetector
local Animation = Instance.new("Animation")
Animation.Parent = game.Workspace
Animation.AnimationId = "http://www.roblox.com/asset/?id=5453580202"
local punch = 1
local addStrength = 0
clicked = true
clickDec.MouseClick:Connect(function(Player)
if punch == 1 then
if not clicked then
return
end
clicked = false
local animTrack = Player.Character.Humanoid:LoadAnimation(Animation)
animTrack:Play()
wait(2)
punch = 2
local players = game.Players:FindFirstChild(Player.Name)
local strength = players:FindFirstChild("leaderstats")["Strength"]
wait(1.5)
addStrength = 5
while strength.Value < 5000 do
wait(1.5)
strength.Value += addStrength
end
elseif punch == 2 then
local animTrack = Player.Character.Humanoid:LoadAnimation(Animation)
animTrack:Play()
animTrack:Stop()
punch = 1
addStrength = 0
wait(2)
clicked = true
end
end)
I tried adding a debounce but that didn't seem to fix the problem. I want the strength stat to increase by 5 every 1.5 secs when the flourbag is clicked, but I noticed that whenever a player spam clicks the flourbag the strength stat starts stacking (i. e. 10 stats or 20 stats at a time instead of 5 every 1.5 secs). How do I fix this?
