I am trying to load a walking animation onto a zombie while it is moving to a waypoint. The zombie moves to the waypoint fine, but the animation doesn’t load, and I am not getting any errors in the output. The zombie is an R6 character. I have searching on the DevForum, but have not found a solution to my problem.
local zombie = script.Parent
-- Animation ID for the walking animation
local walkingAnimationId = "http://www.roblox.com/asset/?id=183294396"
-- Check if the animation ID is not empty
if walkingAnimationId ~= "" then
-- Load the walking animation
local humanoid = zombie:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.AnimationId = walkingAnimationId
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
-- Set the desired walk speed
local zombieWalkSpeed = 8
-- Retrieve the position of the waypoint
local waypointPosition = workspace.Waypoints.Waypoint1.Position
-- Adjust the zombie's walk speed
humanoid.WalkSpeed = zombieWalkSpeed
-- Move the zombie to the waypoint
humanoid:MoveTo(waypointPosition)
else
print("Animation ID is empty. Please provide a valid animation ID.")
end
Add an animator into your humanoid and load the animation through that as loading animations through humanoid is deprecated, you can also try setting the animation priority higher.
I tried playing the animation through the editor, but the animation still wouldn’t play. Here is the updated script:
local zombie = script.Parent
-- Define the animation ID for the walking animation (replace with your animation ID)
local walkingAnimationId = "http://www.roblox.com/asset/?id=183294396"
-- Check if the animation ID is not empty
if walkingAnimationId ~= "" then
-- Load the walking animation
local humanoid = zombie:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
-- Load the animation onto the humanoid's animator
local animation = Instance.new("Animation")
animation.AnimationId = walkingAnimationId
animator:LoadAnimation(animation):Play()
-- Set the desired walk speed
local zombieWalkSpeed = 8
-- Retrieve the position of the waypoint
local waypointPosition = workspace.Waypoints.Waypoint1.Position
-- Adjust the zombie's walk speed
humanoid.WalkSpeed = zombieWalkSpeed
-- Move the zombie to the waypoint
humanoid:MoveTo(waypointPosition)
else
print("Animation ID is empty. Please provide a valid animation ID.")
end
I solved the problem. I found out that the model was actually an R15 blocky character. The reason the animation wasn’t working was because the animation ID was meant for an R6 character. I got an R15 animation, and it worked.