local player = game.Players.LocalPlayer
local Animate
local Humanoid = player.Character:FindFirstChild('Humanoid')
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input,gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.C then
if UIS:GetFocusedTextBox() == nil then
Humanoid.WalkSpeed = 16
local Animation = Instance.new("Animation", player.Character)
Animation.AnimationId = "rbxassetid://03622617391"
Animate = Humanoid:LoadAnimation(Animation)
Animate:Play()
wait()
end
if input.KeyCode == Enum.KeyCode.C then
Animate:Stop()
Humanoid.WalkSpeed = 36
end
end
end
end)
This Doesn't Work
P.S. this is a crawling animation
Is there a way so if you click 'C' and it plays the animation(repeating) and if you click 'C' again then it stops?
I have been done this over an hour but I still don't get any ideas.
Ways I Have Tested
-Using BoolValues
--Using Variables
---The one used in the top script
----Use UIS.InputEnded
and about 10 more ways but they all don't work.
One of the issues are- even though I use a while, repeat loop if I stop moving the character the animation cancels.
Can anybody help?

1 comment
also using an animation while moving automaticaly gets canceled by roblox, if u want an animation u can move around with then u have to script the movement