Ive managed to make a button that when pressed makes you show a sitting animation, but i cant get it to stop. im fine with either clicking again to stop or a seperate button.
Animation-https://www.roblox.com/library/5582851387/Sit-1
Code:
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://5582851387"
local trackanimation = nil
local playability = true
function playAnimation (animationSource)
if playability == true then
local plr = game.Players.LocalPlayer
trackanimation = plr.Character.Humanoid:LoadAnimation (animation)
trackanimation.KeyframeReached:connect (function()
print('hi')
end)
trackanimation:Play()
end
end
script.Parent.MouseButton1Click:Connect(playAnimation)

3 comments
idk why the code pasted weird
animations have a :Stop() function you know https://developer.roblox.com/en-us/api-reference/class/AnimationTrack
yes but i dont know how to tie it into a button