Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Idle doesn't stop after death and unequipped for punch tool?

Asked by
Rdumb1 4
5 years ago
Edited 5 years ago

So this wasn't answered after 4 days and it isn't on the front page so I decided to repost it since the people who tried to answer the question abandoned me.

Problem: The idle animation after death and unequipped does not stop.

Code:

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 deb = false
local cooldown = 1.3

tool.Equipped:connect(function()
local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
idle:Play()
end)

tool.Activated:connect(function()
if deb == true then return end
deb = true
local choose = math.random(1,2)
canattack.Value = true
if choose == 1 then
local swing1animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch1)
swingsound:Play()
swing1animation:Play()
wait(cooldown)
deb = false
elseif choose == 2 then
local swing2animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch2)
swingsound:Play()
swing2animation:Play()
wait(cooldown)
deb = false
end
end)

tool.Deactivated:connect(function()
canattack.Value = false
end)

tool.Unequipped:connect(function()
local hum = char:WaitForChild("Humanoid")
for _,anim in pairs(hum:GetPlayingAnimationTracks()) do
anim:Stop()
end
end)
0
I hate this new editing thing, please revert it back to normal. I can only copy and paste the first line of the code. Rdumb1 4 — 5y
0
^ I dislike it too. Anyways, if you indent the code by pressing "Tab" it should all format as code. Norbunny 555 — 5y
0
o, thanks. Rdumb1 4 — 5y
0
anyone gonna answer? Rdumb1 4 — 5y

Answer this question