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

Not teleporting players to a part in a group called "Spawns"?

Asked by
FiredDusk 1466 Moderation Voter
9 years ago

Not teleporting players to a part in a group called "Spawns"?

for _, player in pairs(game.Players:GetChildren()) do
    local spawns = game.Workspace.Spawns:GetChildren()
    local char = player.Character
  if char ~= nil then
    local num = math.random(1, #spawns)
    local spawnChosen = spawns[num]

        if char ~= nil then
            char:MoveTo(spawnChosen.Position)
        end
    end
end
0
Use CFrame instead of MoveTo 'char.Torso.CFrame = spawnChosen.CFrame' LetThereBeCode 360 — 9y
0
MoveTo will work just fine lukeb50 631 — 9y
0
i ran a little test on this script and i think i got your problem lukeb50 631 — 9y

1 answer

Log in to vote
1
Answered by
lukeb50 631 Moderation Voter
9 years ago

try this. your code fires as soon as the server starts up. put a wait for a few seconds and it should work.

the player is not in Players when the code gets the players table

i did test this solution a lot for you

Ad

Answer this question