Hello, I have been trying to animate my bot but I cannot get the idle animation to work, here is the code I am using, but I don’t know why it keeps walking instead of staying idle
local Humanoid = script.Parent:WaitForChild(“Humanoid”)
Humanoid.StateChanged:Connect(function()
local State = Humanoid:GetState()
if State == Enum.HumanoidStateType.Running then
local LA = Humanoid:LoadAnimation(script:WaitForChild("Walk"))
LA:Play()
elseif State == Enum.HumanoidStateType.Seated then
local LA = Humanoid:LoadAnimation(script:WaitForChild("Sit"))
LA:Play()
elseif State == Enum.HumanoidStateType.Jumping then
local LA = Humanoid:LoadAnimation(script:WaitForChild("Jump"))
LA:Play()
elseif Humanoid.MoveDirection == Vector3.new(0, 0, 0) and State ~= Enum.HumanoidStateType.Jumping and State ~= Enum.HumanoidStateType.Freefall then
local LA = Humanoid:LoadAnimation(script:WaitForChild("Idle"))
LA:Play()
end
end)
Humanoid.StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Running then
local LA = Humanoid:LoadAnimation(script:WaitForChild("Walk"))
LA:Play()
elseif new == Enum.HumanoidStateType.Seated then
local LA = Humanoid:LoadAnimation(script:WaitForChild("Sit"))
LA:Play()
elseif new == Enum.HumanoidStateType.Jumping then
local LA = Humanoid:LoadAnimation(script:WaitForChild("Jump"))
LA:Play()
end
end)
Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
local State = Humanoid:GetState()
local direction = Humanoid.MoveDirection
if direction == Vector3.new() and State ~= Enum.HumanoidStateType.Jumping and State ~= Enum.HumanoidStateType.Freefall then
local LA = Humanoid:LoadAnimation(script:WaitForChild("Idle"))
LA:Play()
end
end)
Also, can’t you just fork the Animate script and convert it to a regular script and put it in the Bot and just change the ids around?
Are you able to fork the Animate script your player gets when you spawn in, copy it, paste it in the Bot and convert it to a regular script? Since from what I see, it’s quite similar to what you’re trying to do with custom animations