:MoveTo() Won't Work in Viewport Frame

Hi there! I’ve been trying to make an NPC walk to a certain position in a viewport frame. I’ve tried using the :MoveTo() function to achieve this, but nothing happens. I understand the position can be incrementally changed to move the NPC, but I want to move the NPC using Roblox physics so animations play properly.

Here’s a snapshot of the hierarchy for the viewport frame:

The script that moves Elizabeth is called MoveElizabeth. This is the code:

The ActiveToggler script present is meant to enable the MoveElizabeth script once the viewport becomes visible. This works fine and I can confirm it’s not the issue. The issue is in the movement itself.

How can I achieve movement using :MoveTo(), or some other physics-based movement function?

2 Likes

You are running the Move-To code in a server script (white script)? If so, server scripts do NOT run on the client. It will only run in ServerScriptService & Workspace (there indeed may be a few more places it can run in, but those are the most common.)

2 Likes

The code still runs on a server script,. I should be using a local script though because this is for the client, so thank you for pointing that out.

Using a local script, the issue still happens.

1 Like

I’ve come up with a solution. Instead of using :MoveTo(), you need to tween the NPC to the desired position. If you want a walking animation to play while this is happening (like I do), you can play the walking animation for the duration of the tween.

Any other method of moving the NPC also works, as long as it doesn’t depend on physics. This means any movement caused by velocity or gravity will not get simulated in a viewport frame. Only changing the position property actually moves an object in a viewport frame. It seems this is just a limitation of them.

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