So, I have a punch tool. It works if I do not have the local ready in there, but thats so you cants spam it. So with it , only the first animation works instead of both, please help.
punch tool script:
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local tool = script.Parent
local swingsound = tool:WaitForChild("Swing")
local canattack = tool:WaitForChild("CanAttack")
local swing1animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch1)
local ready = false
tool.Equipped:connect(function()
local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
idle:Play()
end)
tool.Activated:connect(function()
local choose = math.random(1,2)
if choose == 1 then
local swing1animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch1)
if not ready then
ready = true
swing1animation:Play()
wait(1)
ready = false
elseif choose == 2 then
local swing2animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch2)
if not ready then
ready = true
swing2animation:Play()
wait(1)
ready = false
end
end
end
end)
tool.Deactivated:connect(function()
canattack.Value = true
end)
tool.Unequipped:connect(function()
local hum = char:WaitForChild("Humanoid")
for _,anim in pairs(hum:GetPlayingAnimationTracks()) do
anim:Stop()
end
end)
