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

This script teleports everyone to the same block for some reason, can someone help me fix it?

Asked by 5 years ago
Edited 5 years ago

I want each player to be teleported to a different teleporter.

local plrs = game.Players:GetChildren() wait(70) local teleports = game.Workspace.Teleports:GetChildren() for i,v in pairs(game.Players:GetPlayers()) do local char = v.Character for i,v in pairs(game.Workspace.Teleports:GetChildren()) do

1char:FindFirstChild("HumanoidRootPart").Position = v.Position

end end

0
Could you put ALL the lua into the lua block? I can barely read it. AlphaWolf536791 28 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

It's because you're setting the player's position to the same teleporter at the same time. To make it so it's a different teleporter you would make it so it teleports the player to a teleporter using the index assuming theres the same amount of teleporters as players.

1local plrs = game.Players:GetChildren()
2wait(70)
3local teleports = game.Workspace.Teleports:GetChildren()
4 
5for i,v in pairs(game.Players:GetPlayers()) do
6    local char = v.Character
7    char:FindFirstChild("HumanoidRootPart").Position = teleports[i].Position
8end
Ad
Log in to vote
0
Answered by 5 years ago
1plrs = game.Players:GetChildren()
2wait(70)
3tps = workspace.Teleports:GetChildren()
4for i=1,#plrs do
5    for a=1,#tps do
6        char = plrs[i].Character
7        char:MoveTo(tps[i].Teleport.CFrame.Position)
8    end
9end
Log in to vote
0
Answered by
OnaKat 444 Moderation Voter
5 years ago

You can use :MoveTo() to teleport Model.

I don't know why you put line 1 and line 3

1plrs = game.Players:GetChildren()
2local teleports = game.Workspace.Teleports:GetChildren()

that doesn't do anything.

Here is script

1wait(70)
2 
3for i,plrs in pairs(game.Players:GetPlayers()) do
4    local char = plr.Character
5    for i,teleports in pairs(workspace.Teleports:GetChildren()) do
6        char:MoveTo(teleports.Position)
7    end
8end

Answer this question