local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local crouchAnimation = Instance.new("Animation")
crouchAnimation.AnimationId = "rbxassetid://13010384197"
local crouchAnimationTrack = humanoid:LoadAnimation(crouchAnimation)
local walkAnimation = Instance.new("Animation")
walkAnimation.AnimationId = "rbxassetid://13010388879"
local walkAnimationTrack = humanoid:LoadAnimation(walkAnimation)
local CROUCH_WALKSPEED = 8
local originalWalkSpeed = humanoid.WalkSpeed
local isCrouching = false
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
crouchAnimationTrack:Play()
humanoid.WalkSpeed = CROUCH_WALKSPEED
isCrouching = true
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
crouchAnimationTrack:Stop()
walkAnimationTrack:Stop()
humanoid.WalkSpeed = originalWalkSpeed
isCrouching = false
end
end)
humanoid.Running:Connect(function(speed)
if speed > 0 and isCrouching then
crouchAnimationTrack:Stop()
walkAnimationTrack:Play()
elseif speed == 0 and isCrouching then
walkAnimationTrack:Stop()
crouchAnimationTrack:Play()
end
end)