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

How to use a TextButton to stop an Animation?

I was given this code on the ROBLOX website to stop animations, but I want to connect it to a button. How do I do that?

Thanks for helping me in advance.

script.Parent.MouseButton1Click:connect(function()
    
	void Stop (
    float fadeTime = 0.100000001
)
end)

script.Parent.MouseButton1Click:connect()

1 comment

0

is "script.Parent" is in the button? If so it should work, I think.

1 answer

✓ Accepted answer
local player = game.Players.LocalPlayer
locla character = player.Character
local humanoid = character.Humanoid

--This part stops all currently playing aniamtions
script.Parent.MouseButton1Click:Connect(function()
local anims = humanoid:GetPlayingAnimationTracks()
for i,v in pairs(anims) do
v:Stop()
end
end)

--This part stops a certain playing animation
script.Parent.MouseButton1Click:Connect(function()
local anims = humanoid:GetPlayingAnimationTracks()
for i,v in pairs(anims) do
if v.Name == "Anim" then
v:Stop()
end
end
end)

(not tested in studio)

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