Rooms game entity pathfinding not working

I am trying to make a rooms game and I am trying to make the entity go to the first room door, then the second, etc.

It doesn’t work. The entity just goes to the corner of the room. This is my code for the function:

local function spawnEntity()
	for i, v in pairs(_G.rooms_exist) do
		game.Workspace["A-20"].Humanoid:MoveTo(v.RoomDoor.Position)
		repeat task.wait() until workspace["A-20"].Humanoid.MoveToFinished
	end
end

the table has all of the rooms in the workspace in it

This isn’t how you use MoveToFinished. It will end immediately, because the Event .MoveToFinished always exists. You need to replace this line with workspace["A-20"].Humanoid:MoveToFinished:Wait(). :Wait() will wait until the event fires.

Why have you used game.Workspace the first time, but workspace the second time, instead of workspace for both?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.