help me What is wrong in my script? I made a crawling animation, but when I press 'C', the character only keeps reading and doesn't do the crawling animation.
local crawlSpeed = 8
local walkSpeed = 16
local key = "c"
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local h = player.Character:FindFirstChild('Humanoid')
local anim
wait()
mouse.KeyDown:Connect(function(k)
if k == key then
local Animation = Instance.new("Animation", player.Character)
Animation.AnimationId = "rbxassetid://117559922253648"
anim = h:LoadAnimation(Animation)
anim:Play()
h.WalkSpeed = crawlSpeed
end
end)
wait()
mouse.KeyUp:Connect(function(k)
if k == key then
anim:Stop()
h.WalkSpeed = walkSpeed
end
end).