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

How to stop animation when weapon is removed?

Asked by 5 years ago

So I was able to get the weapon animations to work but whenever I remove the weapon the animation stays in place. I'm not sure how I can stop the animation when the weapon is unequipped. Here is the script

01local plr = game:GetService("Players").LocalPlayer
02local char = plr.Character or plr.CharacterAdded:Wait()
03local h = char:WaitForChild("Humanoid")
04local anim = h:LoadAnimation(script.Parent:WaitForChild("Animation"))
05 
06local tool = script.Parent
07 
08tool.Equipped:Connect(function()
09    anim:Play()
10end)

2 answers

Log in to vote
1
Answered by
poke7667 142
5 years ago

You need to use the Unequipped event to do this. Pretty similar to what you have in the Equipped event but instead use unequipped and have the line: anim:Stop().

Ad
Log in to vote
0
Answered by
pwx 1581 Moderation Voter
5 years ago

This one is pretty self-explanatory. Use a .Unequipped event.

1Tool.Unequipped:Connect(function()
2    anim:Stop()
3end)
0
There we go I wrote that but instead of stop I used destroy or delete. But yeah that should work. Screaming_Monkeys 4 — 5y

Answer this question