How do I add animations to randomly moving AI?

I’m not a scripter, I was looking on youtube on how to make a randomly moving AI. I found a script on youtube, It works but I want it to play a walking animation when the character walks and an Idle animation when the character stops briefly. Can anyone help me?

Here is the script.

local StarterCharacter = script.Parent
local Humanoid = StarterCharacter:WaitForChild("Humanoid")
while wait(1) do
	Humanoid:MoveTo(Vector3.new(math.random(-50,50),0,math.random(-50,50)))
end

You can fork the animations script thats inside your character when you play a game. You just have to press play, then find your character in workspace, then open up the “Animate” script, then you can copy and paste the script then make a new script in the npc and paste the script you copied from your character. And btw use a normal script not a local script

2 Likes

It works now, thanks for telling me!

1 Like