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

How do I make a game queue where everyone stands in a certain location and gets teleported?

I'm trying to make a game where when any player stands in a certain location they all get teleported after a period of time. I have the teleportation script already, but I don't know how to make the queue part.

local MapSelect = script.Parent.MapSelect
local time = 30
local NumberOfMaps = script.Parent.NumberOfMaps.Value
while true do
	repeat wait() until
	script.Parent.time.Value == 0
	MapSelect.Value = math.random(1,NumberOfMaps)
	local player = game.Players:GetPlayers()
	if MapSelect.Value == 1 then

		for i = 1, #player do
			player[i].Character:MoveTo(game.Workspace.Part1.Position)
			script.Parent.time.Value = 3
		end
	end
	if MapSelect.Value == 2 then
		for i = 1, #player do
			player[i].Character:MoveTo(game.Workspace.Part2.Position)
			script.Parent.time.Value = 3
		end
	end
	if MapSelect.Value == 3 then
		for i = 1, #player do
			player[i].Character:MoveTo(game.Workspace.Part3.Position)
			script.Parent.time.Value = 3
		end
	end
	
end

5 comments

0

Queue?

0

By that do you mean teleport players at different times?

0

Those who are confused, I want to make the queue sort of like those games when you stand in a box and when the timer runs out all the players get teleported

0

So you want to tp players after a certain amount of time?

0

Edited the post for clarification

2 answers

✓ Accepted answer

Excuse the bad formatting I'm on mobile.

intermission_interval = 30 --time left in seconds 

function countDown()
        --count down to 0 seconds 
        for i = intermission_interval, 0, -1 do
                print(i, " seconds remaining...")
                wait(1)
        end
end

--start countdown...
countDown() 
--teleport players when countdown is over
teleportPlayers ()

#Edit:

You can keep track of who's in the box calling the box's getTouchingParts() function and adding all the players you find in them into a table

playersInRound = {}
touchingParts = game.Workspace.BoxPart:GetTouchingParts() 

--put all the players touching the brick into the playersInRound table
for _, part in ipairs(touchingParts) do
	if(game.Players:FindFirstChild(part.Parent.Name) and not playersInRound[part.Parent] )then
		table.insert(playersInRound, part.Parent)
	end
end

--and then we can teleport the players by calling the teleport function: 
teleportPlayers(playersInRound)

6 comments

0

Oh sorry I meant that it teleports all the players that are inside a box or a square after the time runs out, not all the players in the lobby.

0

You know if you explained it would help the op

0

just put players that are moved to the box inside of a table and teleport the players in the table once the intermission clock runs out

0

...a table in code (just to be clear)

0

do i need to explain the code better programmerHere?

0

I edited the post to explain how you'd do that

try something like this:

local s = script.Stat
t = 0
while true do
 t = 15
 repeat
  t = t-1
  s.Value = "Intermission.. "..t
  wait(1)
 until t == 0
 s.Value = "Game starting!"
 wait(2)
local plrs = game.Players:GetChildren()
for i = 1,#plrs do
	local num = math.random(1,2)
	plrs[i].Character.Head.CFrame = CFrame.new(workspace.Teleports["Part"..num].Position)
    end
  t=100
repeat
  t = t-1
  s.Value = t.." seconds left"
  wait(1)
  until t ==0
end

this is from zingo dev. check out his vids for the full tutorial. just use this script. here are some links to the vids: first vid https://www.youtube.com/watch?v=SKnbCF4d558 sceond vid https://www.youtube.com/watch?v=UCK1vm1gz-I

4 comments

0

this is kinda confusing to look at....don't teleport players by their head.

0

sorry for the bad format before guys forgot to add the script lines XD

0

no worries i appreciate the effort

0

@royaltoe thx!

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