MoveTo not working in LocalScript? [SOLVED]

Hi, when a player joins, I want the fox to slowly move:


to an unanchored part (called ‘PointE’) on their screen only.

I’ve looked on the Dev Hub & people have had the same problem as me but most of them just forgot to set the Models PrimaryPart. I’ve already set it to the HumanoidRootPart.

This is my LocalScript inside StarterGui:

local fox = game.Workspace:WaitForChild("Fox")
local humanoid = fox:WaitForChild("Humanoid")
local foxPoint1 = game.Workspace:WaitForChild("PointE")

humanoid:MoveTo(foxPoint1.Position)
humanoid.MoveToFinished:Wait()

The fox doesn’t move to the part. Please can someone tell me what I’m doing wrong, thanks & happy easter.

Local scripts, I believe, only work in the player’s character or in locations linked to the player, such as the GUI and tools. They can still transfer your NPC if the local script is inside of these locations, all you have to do is modify the location. x

1 Like

Why you did not use the CFrame of the foxPoint1 ?

1 Like

Thanks for replying, I’ve moved it to StarterCharacterScripts & it’s still not working.

Try placing it in ReplicatedStorage.

1 Like

If I edit this line:

humanoid:MoveTo(foxPoint1.Position)

to this:

humanoid:MoveTo(foxPoint1.CFrame)

I get the error: Unable to cast CoordinateFrame to Vector3

1 Like

Try to place it in ServerScriptService in a script ! :grinning:

1 Like

You can’t make a script into ReplicatedStorage … :neutral_face:

Thanks but when a player joins, I want only them to see the fox move. (sorry if that sounds confusing)

1 Like

I think it’s work, try as even it costs nothing! :wink::grin:

It is what a local script do.
I believe what you did was move the humanoid, which doesn’t affect much on the character. Use MoveTo() on the HumanoidRootPart would be the best.
And, if you’re moving the fox like you said, there is no need to put the local script in StarterCharacterScripts.

1 Like

Where would I put the LocalScript then?

Maybe all of your script is false … :thinking:

Anywhere it can work, like workspace, the StarterCharacterScripts should be used when you want to do a script on the player’s character.

You can try to use MoveTo() on the whole model, or HumanoidRootPart.

1 Like

You should be doing the MoveTo() from the server, also try foxPoint1.CFrame.Position or something else.

If I move the humanoidrootpart instead, I get this error: MoveTo is not a valid member of Part “Workspace.Fox.HumanoidRootPart”

CFrame is the position !
you don’t need to add “.position” ! :neutral_face:

You used HumanoidRootPart.MoveTo(), the right is :MoveTo()

CFrame is the position AND also the orientation, if you just need to use the position, try part.Position instead

That does not make any sense, check the devhub first and here it is; CFrame ~= Position, correct me if I’m wrong.

1 Like