I want to make a crouching script with a startup animation but for some reason it doesn’t really work.
It’s supposed to play an looping animation after the startup animation ends but it doesn’t play it properly. Plus the walking animation doesn’t work either.
I thought it might be because the animation wasn’t looped or the priority was low but even though I changed it, it didn’t work.
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:FindFirstChild("Humanoid")
local uis = game:GetService("UserInputService")
local Animator = hum:WaitForChild("Animator")
local CrouchAnim = game.ReplicatedStorage.Animations.CrouchStartup
local CrouchIdleAnim = game.ReplicatedStorage.Animations.CrouchIdle
local CrouchMoveAnim = game.ReplicatedStorage.Animations.CrouchWalk
local GetDownAnimation = Animator:LoadAnimation(CrouchAnim)
local LoopMoveAnimation = Animator:LoadAnimation(CrouchMoveAnim)
local LoopIdleAnimation = Animator:LoadAnimation(CrouchIdleAnim)
LoopIdleAnimation.Looped = true
LoopIdleAnimation.Priority = Enum.AnimationPriority.Action
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
GetDownAnimation:Play()
if GetDownAnimation.Stopped then
LoopIdleAnimation:Play()
local animateScript = char:WaitForChild("Animate")
animateScript.run.RunAnim.AnimationId = "rbxassetid://11746311681"
animateScript.walk.WalkAnim.AnimationId = "rbxassetid://11746311681"
end
end
end)
uis.InputEnded:Connect(function(input)
LoopIdleAnimation:Stop()
local animateScript = char:WaitForChild("Animate")
animateScript.run.RunAnim.AnimationId = "rbxassetid://9635717140"
animateScript.walk.WalkAnim.AnimationId = "rbxassetid://9635717140"
end)
robloxapp-20221204-2332533.wmv (2.1 MB)