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

Not teleporting everyone?

I have tried this

local pos = Vector3.new(-375.863, 97.1, 834.132)
    for _, player in pairs(game:GetService("Players"):GetPlayers()) do
        if player.Character then
            player.Character:MoveTo(pos)
end
end
end

and roblox's suggested one

target = CFrame.new(0, 50, 0) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
   --Make sure the character exists and its torso exists
   if player.Character and player.Character:FindFirstChild("Torso") then
       --add an offset of 5 for each character
      player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
   end
end

and they both only teleport one person.. its part of a larger script...this is not the only part.

WHATS GOING ON???? Help if you can.

1 comment

0

You could possibly try and use Character.Torso in your script. Because the Torso is welded to all body parts, so it will teleport all parts. And when your more specific... Good stuff happens.

2 answers

The script only runs once - as soon as the game starts. There's only one player right when the game starts. I suggest connecting a function to it (and connecting an event to that function); for example:


game.Players.PlayerAdded:connect(function(player)
local pos = Vector3.new(-375.863, 97.1, 834.132)
--I removed the for loop because this would just teleport the player when they joined.
       repeat wait() until player.Character
            player.Character:MoveTo(pos)
end
end)

2 comments

0

I just wanna correct your terminology. You suggest putting it in a function, and connecting that function to an event.

0

Right, thanks. Corrected that.

local pos = Vector3.new(-375.863, 97.1, 834.132)
while wait() do
--game stuff
for i,v in pairs(game.Players:GetChildren()) do
v.Character:MoveTo(pos)
end
--other game stuff
end


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