Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

¿What should I do if MoveTo does not work properly?

I have a very simple script for an r6 rig in a tower defense game. It is supposed to move towards a total of 3 different points, however, when moving towards the second one, just a couple of studs away from the target position, it turns toward the last point and falls, btu it has not yet rea ched the target position, so I dont know what is going on.

local humanoid = script.Parent.Humanoid

humanoid:MoveTo(workspace.TurnPoints.Start.Position)
humanoid.MoveToFinished:Wait()
humanoid:MoveTo(workspace.TurnPoints:FindFirstChild("1").Position)
humanoid.MoveToFinished:Wait()
humanoid:MoveTo(workspace.TurnPoints:FindFirstChild("2").Position)
humanoid.MoveToFinished:Wait()

2 answers

Well, there can be several things that can be creating the issue. Here, I am assuming that the problem is related to NetworkOwnerShip. I think that the R6 is falling because of continuous change of network owner from the player to the server. To fix that :

-- Add this at the end line

script.Parent.PrimaryPart:SetNetworkOwner(nil)  -- nil = Server

If the above doesn't work, then : For debugging purposes, test the game by using 'Run' and not 'Play' and check whether the R6 is able to complete.

Lemme know if it helps!

2 comments

0

Thanks for the help, but it did not work, the rig still turns before reching the target position, something i noticed though, is that is seems to tern based on time, I reduced the humanoinds WalkSpeed to half, and it actually turned halfway instead of close to the end, even with this line at the end.

0

Did the humanoid went to the points when you tested the game using 'Run'?

MoveTo is not a thing . . . and you cant move a humanoid . . . you need to get the character HumanoidRootPart and then change it position

local player = game.Players.LocalPlayer

player.Character.HumanoidRootPart.Position = vector3.new(0,0,0) --put your position here

3 comments

0

Are you sure about that, cause it does move, it just moves to the next position too soon.

0

do you want it to move to the position or teleport

0

Xx MoveTo is a thing lol. Stop trolling!

This discussion is preserved as it was. New answers, comments, and votes are closed.