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

How can teleport players to spawn locations?

Asked by 9 years ago

I am working on a map changing script. I can't teleport players to the spawns. I am using a server script so I can't access local player(which would be used to teleport the players' torso).

1 answer

Log in to vote
1
Answered by 9 years ago

Well, this is an easy answer. Here it is: So first, what you would do is Get every single player with

for i,v in pairs(game.Players:GetChildren()) do
end

After that, you'd get the character from it.

for i,v in pairs(game.Players:GetChildren()) do
repeat wait() until v.Character ~= nil
end

After this, you can get the Torso from this, and teleport it to the SpawnPoint. ( Being a part or an actual Spawn Point.

for i,v in pairs(game.Players:GetChildren()) do
repeat wait() until v.Character ~= nil
local Character = v.Character
if v.Character.Torso ~= nil then
local Torso = v.Character.Torso
local SpawnPoint = game.Workspace.SpawnPoint
Torso.Position = SpawnPoint.Position
end
end

and there ya have it.

Ad

Answer this question