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

How can I make players teleport to a map from lobby?

I am new to Roblox lua and I was wondering how I could make players from lobby teleport to a map. For example Two Players have joined the game A 30 second countdown starts All players get teleported to their team spawn The Game lasts for 300 seconds then players go back to lobby and the Map dissapears and another 30 second countdown starts and repeats the cycle.

It would mean the world to me if someone would help me :)

Thanks!

2 comments

0

Look up the different types of loops, they will accomplish all those things.

0

you could kill the players to send them to their spawns, if they're already on the right team.

1 answer

Loop through all the players in the game and teleport each one.

function teleportPlayers()
	for i, player in ipairs(game.Players:GetChildren()) do
   	--Make sure the character exists and its HumanoidRootPart exists
   if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
       
			 player.Character.HumanoidRootPart.CFrame = game.Workspace.TeleportPlace.CFrame + Vector3.new(0, i * 5, 0)
     --add an offset of 5 for each character
		end
	end
end

Put this code in a script and call the function using "teleportPlayers()"

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