Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My Tool's animation isn't stopping when its supposed to?

Idea: I've made a tool in Roblox studio with an animation whenever you equip the tool. If you suddenly equip the tool it'll play the animation of you bringing it up.

Problem: If you equip the tool and suddenly unequip the tool while the animation is playing, the animation will just kinda be still.

example: https://streamable.com/k8824p

The beginning is what happens when you play through the whole animation, this part is fine, as it goes to where it needs to go. The last part is what the problem is, you can see that I equip the tool and then immediately unequip it. This makes the next animation play for some reason.
I've highlighted the important parts(Which parts make the tool's animation play)

Script:

wait(1)
local Player = game.Players.LocalPlayer
local dance = Player.Character.Humanoid:LoadAnimation(script.Parent.Animation) -- the holding animation
local Action = Player.Character.Humanoid:LoadAnimation(script.Parent.ACtion)
local Speed= 28
local DefaultSpeed= 16
local Fork = Player.PlayerGui:WaitForChild("ScreenGui").TrustyFork
local Hands = Player.PlayerGui:WaitForChild("ScreenGui").Hands
local Grunt = game.Workspace.ClimbGrunt
local BringUp = Player.Character.Humanoid:LoadAnimation(script.Parent.Bringup) -- Bringing up Animation Variable

local Tool = script.Parent

Tool.Equipped:Connect(function()
	BringUp:Play() -- Brings the tool up to your view
	wait(.5) -- how long the animation takes
	dance:Play() -- Holds the tool still
	Player.Character.Humanoid.WalkSpeed = Speed
	Fork.Visible = true -- Visible Part
	Hands.Visible = false -- Visible Part
end)

Tool.Unequipped:Connect(function()
	BringUp:Stop() -- Should stop the bringing up animation 
	dance:Stop() -- Should stop the holding animation
	Player.Character.Humanoid.WalkSpeed = DefaultSpeed
	Hands.Visible = true -- Visible Part
	Fork.Visible = false -- Visible Part
end)


Tool.Activated:Connect(function()
	Action:Play()
	Grunt:Play()
wait(1)
	dance:Play()
end)

1 comment

0

On line 16 wait 5 seconds it might take it away after the 5 seconds

1 answer

✓ Accepted answer

I believe what is happening is that the animation stops wherever its at when playing, so if its a 5 second long animation and you stop it 2 seconds after it will just pause there. If its like a holding animation of ur character just holding the tool then make it 0 seconds long or 0.1

if its like a animation of your character like doing something specific like exp: lifting animation; then i suggest just letting it play out and it will just stop after its done.

if none of this is the case and its say a idle animation that loops constantly and is a few seconds long then you would have to make the script create the animation when you equip the tool and then destroy it when you unequip.

or wait 0.5 and then stop the (Dance) animation

hopefully this helped you in some way!

if the problem continues to occur it might be a animation glitch or you have to change the animation priority.

This discussion is preserved as it was. New answers, comments, and votes are closed.