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

How to use a TextButton to stop an Animation?

Asked by 6 years ago
Edited 6 years ago

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()
0
is "script.Parent" is in the button? If so it should work, I think. HeyItzDanniee 252 — 6y

1 answer

Log in to vote
0
Answered by
Nikkulaos 229 Moderation Voter
6 years ago
Edited 6 years ago
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)

Ad

Answer this question