I am following a Youtube tutorial and written the code below:
local function animateMob(object)
local humanoid = object:WaitForChild("Humanoid")
local animationsFolder = object:WaitForChild("Animations")
if humanoid and animationsFolder then
local walkAnimation = animationsFolder:WaitForChild("Walk")
if walkAnimation then
local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid)
local walkTrack = animator:LoadAnimation(walkAnimation)
walkTrack:Play()
end
else
warn("No humanoid/animation folder for", object.Name)
end
end
workspace.Mobs.ChildAdded:Connect(animateMob())
But for some reason, the humanoids (Mobs) doesn’t walk following the animations:
Gnomecode himself made the animation I suppose, you can’t use animations that are not owned by you ( that you didn’t make the animation ). You have to make your own animation.
What @2kvigilanxe was trying to say is, it is not your respective asset and only you can use your own. That means the owner of the animation asset can only use their own, so as yours.
local humanoid = object:WaitForChild("Humanoid")
local animationsFolder = object:WaitForChild("Animations")
if humanoid and animationsFolder then
local walkAnimation = animationsFolder:WaitForChild("Walk")
if walkAnimation then
local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid)
local walkTrack = animator:LoadAnimation(walkAnimation)
walkTrack:Play()
end
else
warn("No humanoid/animation folder for", object.Name)
end
end
workspace.Mobs.ChildAdded:Connect(animateMob())
local function animateMob(object)
local humanoid = object:WaitForChild("Humanoid")
local animationsFolder = object:WaitForChild("Animations")
if humanoid and animationsFolder then
local walkAnimation = animationsFolder:WaitForChild("Walk")
if walkAnimation then
local walkTrack = humanoid:LoadAnimation(walkAnimation)
repeat task.wait() until walkTrack.Length > 0
walkTrack:Play()
end
else
warn("No humanoid/animation folder for", object.Name)
end
end
workspace.Mobs.ChildAdded:Connect(animateMob)