**Greetings,
I have been trying to make an animation load when a certain key is pressed. Succeeded, however, my problem is how do I make the same animation stop if the same key is pressed? It is a meditating animation.
I put the script down below. I would really appreciate some help.
Best wishes, Amydamaru**
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.Character:Added()
local humanoid = character:WaitForChild("Humanoid")
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://375479668"
function playAnimation(Anim)
local track = humanoid:LoadAnimation(Anim)
track:Play()
end
game:GetService("UserInputService").InputBegan:connect(function(input ,proc)
if not proc then
if input.KeyCode == Enum.KeyCode.F then
playAnimation(anim)
end
end
end)

1 comment
Thank you very much for your help.