Humanoid:MoveTo not working on my NPC (client-side)

Hi!

I am making an “intro-cutscene” effect for my old-style RPG game. In this cutscene there are obviously camera movements (fine), character movements (not fine). As multiple people will be in one server the character movements will need to happen on the client.

The issue here is that my NPC.Humanoid:MoveTo() function is not working at all; it doesn’t provide any error nor stops the script from running, it merely just ignores this line of code:

game.Workspace.Tooby.Humanoid:MoveTo(Vector3.new(-255, 89, 253.5))

-255, 89, 253.5 are the co-ordinates of the red part here (Tooby is the name of the highlighted noob NPC):

I will now provide a chunk of my script around this line of code:

camera.CFrame = cameras:WaitForChild("camera5").CFrame

game.Workspace.Tooby.Humanoid:MoveTo(Vector3.new(-255, 89, 253.5)) -- line of code that doesn't work

CSchat.Chat(player, "GUYS!", "Tooby", 1)
camera.CFrame = cameras:WaitForChild("camera6").CFrame
CSchat.Chat(player, "We've just heard news that a PLAYER has joined the game!", "Tooby", 2)
CSchat.Chat(player, "They are believed to be called " .. player.Name .. ".", "Tooby", 3)

As you can see, “GUYS!” is the dialogue that appears after calling Tooby to walk. (CSchat is a modulescript which just displays the parameters on a GUI).

However, Tooby remains in the same position even when the dialogue after his movement has been shown:

I have searched around the forum but all similar problems seem to have solutions which did not work for me.

I attempted to wrap this line of code in a pcall function to see if anything would show…

local success, err = pcall(function()
	game.Workspace.Tooby.Humanoid:MoveTo(Vector3.new(-255, 89, 253.5)) 
end)
print(success, err)

…but the only thing in output was this:
11:08:08.801 true nil - Client - StartScene:46

Now, I wanted to make sure there wasn’t a problem with the model itself, so I tried to run a MoveTo function on the server using a remote event, and there were no issues. But I need this to be on the client otherwise everyone will see the NPC movement.

I’ve fixed almost all my problems with forums, videos etc… but this… this I have no clue. Maybe I am missing something or this is a Roblox bug?

Thanks.

1 Like

Is the NPC created by the client or does it already exist on the server?

1 Like

You need to give the client network ownership of the NPC if it is created on the server. You can do this by looping through the NPCs body parts and calling the :SetNetworkOwner(player) function.

If your game is multiplayer, create the NPC on the client.

2 Likes

It already exists on the server. It’s just being “moved” by the client, if that makes sense.

As @Tom_atoes mentioned you should create the NPC on the client if no other players need to see the NPC. Then you should be able to call MoveTo on the humanoid.

Otherwise, if you wanted the NPC to exist for all players as you have it currently, you would need to set network ownership to the controlling client. Alternatively, you would need to create the NPC on each client and sync it between other clients through the server.

1 Like

Perfect! Worked, thank you very much.