This script plays a crouching animation and idle while holding C, though only half the crouching movement animation is played
is there something wrong with the script? i tried multiple animations and they all do it
local Player = game.Players.LocalPlayer
local Humanoid = Player.Character:WaitForChild('Humanoid')
local RunAnimation = Instance.new('Animation')
local humanim = Player.Character.Humanoid:LoadAnimation(script.CrouchAnimation)
local humanimid = Player.Character.Humanoid:LoadAnimation(script.CrIdleAnimation)
Running = false
local WalkingSpeed = 10
local CrouchSpeed = 7
function Handler(BindName, InputState)
if InputState == Enum.UserInputState.Begin and BindName == 'RunBind' then
Running = true
Humanoid.WalkSpeed = CrouchSpeed
humanimid:Play()
elseif InputState == Enum.UserInputState.End and BindName == 'RunBind' then
humanim:Stop()
humanimid:Stop()
Running = false
Humanoid.WalkSpeed = WalkingSpeed
end
end
Humanoid.Running:Connect(function(Speed)
if Running and not humanim.IsPlaying then
if Speed >= CrouchSpeed - 1 then
humanim:Play()
Humanoid.WalkSpeed = CrouchSpeed
end
elseif not Running and humanim.IsPlaying then
if Speed < CrouchSpeed - 1 then
humanim:Stop()
humanimid:Stop()
Humanoid.WalkSpeed = WalkingSpeed
end
end
end)
Humanoid.Changed:Connect(function(property)
if property == "Jump" and humanim.IsPlaying then
humanim:Stop()
humanimid:Stop()
end
end)
game:GetService('ContextActionService'):BindAction('RunBind', Handler, true, Enum.KeyCode.C)