Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How come the script isn't teleporting everyone?

Hello everybody. So I want to teleport players to a brick. But the script below only teleports 1 player in the server. And not everyone. How do I fix it? Thanks.

--spawns is the part i want people to teleport to
spawns = game.Workspace.spawns

for i,v in pairs(game.Players:GetPlayers()) do
		local name = v.name
			local checkplayer = check:FindFirstChild("Humanoid")
			if checkplayer then
                v.Character.HumanoidRootPart.CFrame = spawns.CFrame

1 comment

0

Correction: Line 6 is local checkplayer = v.Character:FindFirstChild("Humanoid")

1 answer

✓ Accepted answer

When the game starts, this script is running instantly, and probably most of the player's characters haven't loaded in yet. This means checkplayer would be nil and the teleportation wouldn't take place.

You can add a wait in the beginning but I suggest you change

local checkplayer = check:FindFirstChild("Humanoid")

to

local checkplayer = check:WaitForChild("Humanoid")

This would hold the script until the child is found, which is the Humanoid. This would mean it won't skip over certain players who haven't fully loaded in yet, it would wait for them.

This discussion is preserved as it was. New answers, comments, and votes are closed.