So I am trying to make a game, but that game requires a crawl animation. I made a bad crawling animation for script testing purposes but if I stand still and activate my script, my animation starts, but if I move, it stop. vise versa, if I move while activating it, it will play my animation while I'm moving and if I stop moving, then my animation stops. So what I want is to start the animation with c, then it will go forever, regardless whether I move or not and when I start the animation, then when I press either x or c, it will stop. Please leave anything you think might work. (here's the script, I'm just starting scripting, the script is in between the lines)
local animation = Instance.new("Animation")
animation.AnimationId = "https://www.roblox.com/Asset?ID=01473278473"
local trackanimation = nil local playability = true local isCrawling = false
function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
if playability == true then
local plr = game.Players.LocalPlayer
trackanimation = plr.Character.Humanoid:LoadAnimation(animation)
trackanimation.KeyframeReached:connect(function(kf)
end)
trackanimation:Play()
end
end
end
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.C)

2 comments
It's weird but that entire separated text is the script, even though they made it weird.
there is an edit button btw, you can edit the mistake.