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

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

Asked by 5 years ago

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

0
Queue? royaltoe 5144 — 5y
0
By that do you mean teleport players at different times? royaltoe 5144 — 5y
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 rubiksmaster301 17 — 5y
0
So you want to tp players after a certain amount of time? royaltoe 5144 — 5y
0
Edited the post for clarification royaltoe 5144 — 5y

2 answers

Log in to vote
2
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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)
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. rubiksmaster301 17 — 5y
0
You know if you explained it would help the op programmerHere 371 — 5y
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 ForeverBrown 356 — 5y
0
...a table in code (just to be clear) ForeverBrown 356 — 5y
View all comments (2 more)
0
do i need to explain the code better programmerHere? royaltoe 5144 — 5y
0
I edited the post to explain how you'd do that royaltoe 5144 — 5y
Ad
Log in to vote
-2
Answered by 5 years ago
Edited 5 years ago

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

0
this is kinda confusing to look at....don't teleport players by their head. ForeverBrown 356 — 5y
0
sorry for the bad format before guys forgot to add the script lines XD Cynical_Innovation 595 — 5y
0
no worries i appreciate the effort royaltoe 5144 — 5y
0
@royaltoe thx! Cynical_Innovation 595 — 5y

Answer this question