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

How do you teleport(All) players?

I don't know how... Do you have to use BodyPosition? Or Cframe? I'm confused... I'm using

local player = game.Players:GetPlayers()
for i = 1, #player do
player[i].Character:MoveTo(Vector3.new(0,2,0))

Is it right? I know it's right but Why is it only teleporting one person? Not all the players? Also, why is the game working in Studio but not in actual gameplay? It said here that you might need to do localscript but I tried it but It never worked.

4 answers

Hey there what I would do in your case is use this efficient script found in the Roblox Wiki

wait(30)--Can be any other time
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
	player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
	--add an offset of 5 for each character
end

If you want to learn more about teleportation check this link: http://wiki.roblox.com/index.php?title=Teleportation

1 comment

0

it does not work anymore (for my script anyway)

You could make your own function :3

function teleAll(x, y, z)
	local pos = Vector3.new(x, y, z)
	for _, plr in pairs(Game:GetService("Players"):GetPlayers()) do
		if plr.Character then
			plr.Character:MoveTo(pos)
		end
	end
end

teleAll(0, 2, 0)

2 comments

0

thank you

0

it worked thanks :D

It looks like you've forgot an end. Here's the fixed code:

local player = game.Players:GetPlayers()
for i = 1, #player do
player[i].Character:MoveTo(Vector3.new(0,2,0))
end

Hope I've helped! If this doesn't work, just comment and I'll be glad to help.

1 comment

1

Oh sorry... I didn't post the whole script...

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