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

Why does animation still play when tool unequips?

Asked by 3 years ago
Edited 3 years ago

I want to make it where when i equip a tool a animation plays, and when i unequip it, the animation should stop. When i unequip it, the animation still plays.

help

01local Tool = script.Parent
02local Animation = Tool.Animation
03 
04 
05 
06 
07 
08Tool.Equipped:Connect(function()
09 
10    local Player = Tool.Parent
11    local Humanoid = Player.Humanoid
12    local Animator = Instance.new("Animator")
13 
14    local AnimationPlay = Humanoid.Animator:LoadAnimation(Animation)
15 
View all 33 lines...

1 answer

Log in to vote
0
Answered by
1JBird1 64
3 years ago

instead of:

1local AnimationPlay = Humanoid.Animator:LoadAnimation(Animation)
2 
3AnimationPlay:Stop()

try:

1for i,child in pairs(Humanoid:GetPlayingAnimationTracks()) do
2 if child.Animation.AnimationId == “rbxasset//insert_animation_id” then
3  child:Stop()
4 end
5end

hopefully it works out :D

Ad

Answer this question