Rig not moving correctly/ how to move correctly?

Hi, i was wondering how i could make a rig move in a random direction, when it goes into a folder, which happens every 5ish seconds.
Im wondering if i can use humanoid:Move or :MoveTo, as i want it to basically act like an animal.

Is this something i could use?

   local rigFolder = workspace.rigFolder
   
   rigFolder.ChildAdded:Connect(function(rig)
        local humanoid 
= rig:FindFirstChild("Humanoid")

if humanoid then 
      humanoid:MoveTo(Vector3.new(math.random(-5, 5), 0, math.random(-5, 5))
end

sorry if my code is a little strange, i couldn’t copy it over from studio.
sadly, the rig keep stopping, and im 99% sure
its a flat plain. can anyone help?

[EDIT]
Is there a simple way to just make an animal type movement, preferably server side as this doesn’t seem to work very well.

Im pretty sure they will both work the same.

1 Like

do you know whats going wrong?
it keeps stopping st random points, and doesn’t always move. Ok i will try lengthening it.

if this is what you mean by “happens every 5 seconds”, then this is very bad

math.random returns a random integer between min and max → (1, 6) → 3
it does NOT wait out the result

i cna’t really see a while loop in your code snippet lol


also, your character will always walk to the center of the map to the vector3 coordinates, this is because you just apply vector3 coordinates, not add them from the character’s position

local randomInt = math.random(-5, 5)
local goalPosition = characterRootPart.Position + Vector3.new(randomInt, 0, randomInt)

humanoid:MoveTo(goalPosition) -- will wander around in a range of -5/5 studs, NOT walk to the -5/5 vector3 coordinates
1 Like

what is bad about happening every 5 second? (and that math.random does not return the result) also, the child added is first every five seconds, but for different children as i have a script which clones the rigs from replicated storage, and puts it into the folder, which should fire childadded. Thanks for the vector 3 info, i forgot that it couldnt be relative to the rig.

Also, im trying to make it move once, cos of i can figure out how to do that, i can make the rig move every few seconds.