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

    char: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.

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 
    char:FindFirstChild("HumanoidRootPart").Position = teleports[i].Position
end
Ad
Log in to vote
0
Answered by 5 years ago
plrs = game.Players:GetChildren()
wait(70)
tps = workspace.Teleports:GetChildren()
for i=1,#plrs do
    for a=1,#tps do
        char = plrs[i].Character
        char:MoveTo(tps[i].Teleport.CFrame.Position)
    end
end
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

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

that doesn't do anything.

Here is script

wait(70) 

for i,plrs in pairs(game.Players:GetPlayers()) do 
    local char = plr.Character 
    for i,teleports in pairs(workspace.Teleports:GetChildren()) do
        char:MoveTo(teleports.Position)
    end
end

Answer this question