I wanna stop a animation by clicking a button again, but I don’t know how I could approach this.
Code: (way too lazy to mess with the devforum formatting)
How could I stop it after “else”?
dont complain about the messy code
I wanna stop a animation by clicking a button again, but I don’t know how I could approach this.
Code: (way too lazy to mess with the devforum formatting)
How could I stop it after “else”?
dont complain about the messy code
This right here, it’s deprecated but there’s no other way to get a track without arguments, unless you make a function above your click function, where a bool.Changed:Wait() is used, after that, the animationtrack passed as an argument is stopped
local function animation(track)
track:Play()
bool.Changed:Wait()
track:Stop()
end
I personally use Stopped.Wait() the same way, but your request is different, as the track is looped.
There is a non deprecated function for the animator object.
humanoid.Animator:GetPlayingAnimationTracks()
Holy cows! I didn’t know, thank you.
Yeah that was what I was using before but it didn’t work.
What code did you use for that?
I checked the playing animations and see if there was a animation playing named “Funny”, (name of the animation instance) but I don’t have the exact code as it’s deleted now, and I can’t remember it.
So how’s the function bool change?
anim:Stop()
Just make your local anim outside the mouse button 1 down function, and play it inside the ye == false check.
Also, don’t use MouseButton1Down, use Activated, as its mobile compatible.
All you’d have to use is: Animation:Stop()
local tracks = animator:GetPlayingAnimationTracks()
for _, track in pairs(tracks) do
if track.Looped then
track:Stop()
end
end