The animation does not work even though it works normally in the animation editor

  1. What do you want to achieve?
    I want my character to turn on animations when I click the C key, but the animation doesn’t work

  2. What is the issue?
    The problem is that in the animation editor the animation works normally, but when I click the C button the animation does not work and the character takes an exclamation point pose

After Click C:

image

Code:

local TweenService = game:GetService("TweenService")
local Humanoid = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid")
local HumanoidRootPart = game:GetService("Players").LocalPlayer.Character:WaitForChild("HumanoidRootPart")

local CrouchAnimation = script.CrouchAnimation
local CrouchTrack = Humanoid:LoadAnimation(CrouchAnimation)

local CameraInfo = TweenInfo.new(
	0.3,
	Enum.EasingStyle.Quint,  
	Enum.EasingDirection.Out,  
	0,                
	false,         
	0  
)

local CrouchedGoal = {CameraOffset = Vector3.new(0,-1.75,0)}
local UncrouchedGoal = {CameraOffset = Vector3.new(0,0,0)}

local CrouchedTween = TweenService:Create(Humanoid, CameraInfo, CrouchedGoal)
local UncrouchedTween = TweenService:Create(Humanoid, CameraInfo, UncrouchedGoal)

local inCrouch = false

local function Crouch()
	if inCrouch == false then
		inCrouch = true
		CrouchedTween:Play()
		Humanoid.WalkSpeed = 8
		CrouchTrack:Play()

		HumanoidRootPart.CanCollide = false
		
	else
		inCrouch = false
		UncrouchedTween:Play()
		Humanoid.WalkSpeed = 16
		CrouchTrack:Stop()
		
		HumanoidRootPart.CanCollide = true
		
	end
end

game:GetService("UserInputService").InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.C then
		Crouch()
	end
end)
  1. What solutions have you tried so far?
    Currently I can’t find why this is happening and that’s why I’m writing
1 Like

Is the animation looped, and is the animation priority at Action4?

The animation is looped and has priority Action4

I found problem :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.