Hello, so here is the script that i made, after you press R it should play animation when you have your arms crossed, until you press R again to stop the animation. But instead it started playing the animation, and even if i pressed R again it didnt stop. i tried putting print "case a" and print "case b" to both if functions, and in output when i pressed R it only showed me case a, basically the first "if". Also, can the reason be that my animation is looped?(also i already tried writing anim:Stop() instead of anim:Destroy(), it still didnt help). Thank you all in advance.
Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
local anim = nil
--Put me in StarterGui
mouse.KeyDown:connect(function(key)
key = key:lower()
if key == "r" then
anim = Player.Character.Humanoid:LoadAnimation(script.TestAnim)
anim:Play()
elseif key == "r" then
if anim ~= nil then
anim:Destroy()
end
end
end)

1 comment
Hello, I have an error "Humanoid is not a valid member of the model