Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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!

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. boyparis 14 — 4y
0
Did the humanoid went to the points when you tested the game using 'Run'? BestCreativeBoy 1395 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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
0
Are you sure about that, cause it does move, it just moves to the next position too soon. boyparis 14 — 4y
0
do you want it to move to the position or teleport Xx0966xX 41 — 4y
0
Xx MoveTo is a thing lol. Stop trolling! M9F 94 — 3y

Answer this question