Problem with GUI script
My GUI stop animation script (R6) isn’t working.
I have tried looking for another forum to see if someone else has had the problem.
function leftClick () print ("(player.Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop()") end script.Parent.MouseButton1Click:Connect (leftClick)
is what I’ve been trying to do, I’ve also looked at official roblox tutorials, and those haven’t worked either. (I don’t have much scripting experience, but I am somewhat familiar with it.)
function leftClick ()
print ("(player.Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop()")
end
ShyGuy Gaem - Roblox
(PS, I cannot do a reset script, due to the camera disabling if you respawn.)
1 Like
here’s the code in a readable state for anyone wanting to solve this
function leftClick ()
print ("(player.Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop()")
end
script.Parent.MouseButton1Click:Connect (leftClick)
2 Likes
This should work:
function leftClick()
print("(player.Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop()")
end
script.Parent.MouseButton1Click:connect(leftClick)
If it doesn’t work, check if you’re correctly referencing the button.
1 Like
kk! I am trying it right now, hopefully it works
hmm, should it be a local script?
It has to be a local script, since we’re dealing with UI.
1 Like
kk, It needs to be into StarterGUI right? Sorry for the inconvienence btw
1 Like
The local script should be added in the button in the StarterGUI since it was referenced as “script.Parent”
oh, I don’t know what could be wrong then.
1 Like
Are you trying to stop EVERY animation in your character? Because what you’re currently doing is getting any tracks from the humanoid and stopping them, which means you will also stop idle/running/jumping/etc. animations. I recommend making the tracks have a specific name and then stopping them if the name is equal to the one you chose.
For instance, here’s a practical example:
for _, PlayingTrack in ipairs(Humanoid:GetPlayingAnimationTracks()) do
if PlayingTrack.Name == "Emote" then -- checks if the playing animation is called "Emote" so I don't interfere with movement animations such as the ones I mentioned before
PlayingTrack:Stop();
PlayingTrack:Destroy();
end;
end;
Just do this script:
function leftClick()
script.Parent.MouseButton1Click:connect(function(player)
if script.Parent.MouseButton1Click then
print("(player.Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop()")
end
end)
end
leftClick()
How can this possibly work? This is just printing the code you’re trying to execute (that is also wrong because you need to use ipairs or pairs when looping with GetPlayingAnimationTracks).
I tried that script, doesn’t seem to be working.(I am using an animation tool, and I need it to stop the animation playing from the tool, with some of the animations, from other tools, being looped.)
He is just printing it out, the code doesn’t need a loop.
Use this:
function leftClick()
script.Parent.MouseButton1Click:connect(function(player)
print("(player.Character.Humanoid:GetPlayingAnimationTracks()) do v:Stop()")
end)
end
leftClick()
I tested it out and it prints as expected.
I think its printing, just not actually ending the animation