So I'm making an elevator that teleports players that enter it. When it has 2, 3, or 4 players it teleports the players. When players enter it, it sticks there character names in a table. So I'm trying to make a for loop that searches for their character in workspace but it is not working.
Heres the code:
local function Teleport() --Teleports players to tracks
local St1 = Points.StartingLine1
local St2 = Points.StartingLine2
local St3 = Points.StartingLine3
local St4 = Points.StartingLine4
for index, value in pairs(game.Workspace:GetChildren()) do
local value = game.Workspace[index]
if value.Name == PlayerArray[1] then
value:FindFirstChild("HumanoidRootPart").CFrame = St1.CFrame + Vector3.new(0,5,0)
elseif value.Name == PlayerArray[2] then
value:FindFirstChild("HumanoidRootPart").CFrame = St2.CFrame + Vector3.new(0,5,0)
elseif value.Name == PlayerArray[3] then
value:FindFirstChild("HumanoidRootPart").CFrame = St3.CFrame + Vector3.new(0,5,0)
elseif value.Name == PlayerArray[4] then
value:FindFirstChild("HumanoidRootPart").CFrame = St4.CFrame + Vector3.new(0,5,0)
end
end
end
Any idea's?

1 comment
make a loop with _ while true do ...... end