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

0 Works in studio but not in game. How to use a TextButton to Stop an Animation?

Asked by 6 years ago

Someone assisted me in getting this far, but I wanted to know how to get the code working for studios, but not in game, what is stopping it from actually working?

Thanks in advance.

It is a LOCAL SCRIPT.

local player = game.Players.LocalPlayer

local character = player.Character

local humanoid = character.Humanoid

script.Parent.MouseButton1Click:Connect(function()

local anims = humanoid:GetPlayingAnimationTracks()

for i,v in pairs(anims) do

v:Stop()

end

end)



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)
0
Try using WaitForChild to stop any loading error. TiredMelon 405 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Thanks guys, with a bit of research that you've sent, I got it.

local player = game.Players.LocalPlayer

local character = player.Character

local humanoid = character:WaitForChild("Humanoid")

script.Parent.MouseButton1Click:Connect(function()

local anims = humanoid:GetPlayingAnimationTracks()

for i,v in pairs(anims) do

v:Stop()

end

end)



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)
Ad

Answer this question