local Char = script.Parent
local Hum = Char:WaitForChild("Humanoid")
local Animator = Hum:WaitForChild("Animator")
local Idle:AnimationTrack = Animator:LoadAnimation(script:WaitForChild("CrouchIdle"))
Idle.Priority = Enum.AnimationPriority.Idle
local Walk:AnimationTrack = Animator:LoadAnimation(script:WaitForChild("CrouchWalk"))
Walk.Priority = Enum.AnimationPriority.Movement
local UIS = game:GetService("UserInputService")
local Crouching = false
local function HandleCrouching()
Hum.HipHeight = -1.5
while Crouching == true do
if Hum.MoveDirection.Magnitude ~= 0 then
Idle:Stop(0)
Walk:Play(0,10,1)
else
Walk:Stop(0)
Idle:Play(1,5,0)
end
wait()
end
Idle:Stop(1)
Hum.HipHeight = 0
Walk:Stop(0)
end
UIS.InputBegan:Connect(function(i,gpe)
if not gpe then
if i.KeyCode == Enum.KeyCode.C then
Crouching = not Crouching
HandleCrouching()
end
end
end)
Code
So I am making a crawl system and in it I have made the crawl animation… duh anyways so it kinda jitters it plays a bit like in the middle then jitters rappidly:
Maybe something like this. Im editing the AnimateScript from roblox too. So the run while crouch is a different animation too.
Player should hold “C” key to stay crouched. (I just made a quick stupid crouch animation xD)
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local CrouchAnim = script:WaitForChild("CrawlAni") -- Player getting crouch without moving animation
local CrouchTrack
UIS.InputBegan:Connect(function(k, event)
if k.KeyCode == Enum.KeyCode.C then
CrouchTrack = Player.Character.Humanoid.Animator:LoadAnimation(CrouchAnim)
CrouchTrack:Play()
local animateScript = Player.Character:WaitForChild("Animate")
animateScript.run.RunAnim.AnimationId = "rbxassetid://0000000" -- Set the crawling movement animation
end
end)
UIS.InputEnded:Connect(function(k, event)
if k.KeyCode == Enum.KeyCode.C then
CrouchTrack:Stop()
local animateScript = Player.Character:WaitForChild("Animate")
animateScript.run.RunAnim.AnimationId = "rbxassetid://913376220" -- Restore original run animation
end
end)