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

Help me with MoveTo() ?

Asked by
iLegitus 130
9 years ago
TPTO = game.Workspace.Map.TELEPORTBRICK

for i = 1, #Players do 
    sr = game.ReplicatedStorage["TOOL_Drive"].StarterRod:clone()
        sr.Parent = Players[i].Character:MoveTo(TPTO,Position)
        end

So for some reason,Its not working. Im trying to teleport ALL the players to the part,It wont work tough.

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

Errors would have appeared in the output, in the future, please include them.

So many problems here. First, on line one Mapand TELEPORTBRICKmay not be loaded yet, so you should use WaitForChild(). #Players is a nil value, because 'Players' does not exists. You have to define it as a variable somewhere. Then in the loop, you clone something in ReplicatedStorage then set it's parent to Players[i].Character"MoveTo(TPTO,Position)? That makes no sense. Are you trying to move the character or set the clone's parent? Because you can't set something's parent to the MoveTo()method. 'Postion' is also nil. I assume that you meant TPTO.Position instead of TPTO,Position? Anyways, try this:

I also changed the name of some of the variables, to make them more consistent with the style most people use and prefer to read.

local teleBrick = game.Workspace:WaitForChild("Map"):WaitForChild("TELEPORTBRICK")

local players = game.Players:GetPlayers()
for i = 1, #players do
    if players[i].Character then --Makes sure the character exists
        players[i].Character:MoveTo(teleBrick.Position)
    end
end
Ad

Answer this question