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 Put 2 Items/Players in a Single Variable?

    for i, v in pairs(playersInRoomOne) do
        local theMainText = v.PlayerGui.RoomsGui.RoomOne.mainText.TextLabel
        v.PlayerGui.RoomsGui.RoomOne.mainText.TextLabel.Visible = true

This works, but let's say If I Do

    for i, v in pairs(playersInRoomOne) do
        local theMainText = v.PlayerGui.RoomsGui.RoomOne.mainText.TextLabel
        theMainText.Text = "Game starting in 3...."
	wait(1)
        theMainText.Text = "Game starting in 1...."
	wait(1)
	theMainText.Text = "Game starting in 2...."
	wait(1)
	theMainText.Text = "Game started..."

The Text will go for player one first

Game Starting in 3...

Game Starting in 2...

Game Starting in 1...

Then for Player Two

Game Starting in 3...

Game Starting in 2...

Game Starting in 1...

I tried to put them in a variable

local RoomOnePlayersVar = playersInRoomOne[1] and playersInRoomOne[2]

But it doesn't work, nothing happens when I use the variable, Any Help?

1 answer

You can achieve this by using a table. This is a datatype that supports multiple Instances and datatypes to be stored into on container by reference of a single name:

local RoomOnePlayersTab = {
	playersInRoomOne[1]; playersInRoomOne[2]
}

Otherwise, you can use single-line declaration—though, this doesn't store both into one:

local PlayerA, PlayerB = playersInRoomOne[1], playersInRoomOne[2]

You can use a for loop to create a countdown shortcut:

for i = 3,1,-1 do
	theMainText.Text = "Game starting in "..i.."...."
	wait(1)
end

6 comments

0

Basically, You just told me nothing :/ On my Script, I already created the table, and the second method doesn't even work >.<

0

This is all you can do.

0

Let's say if you would want to make a game, and to teleport all players in game, and lets say you needed to use Wait what would you use, Maybe that could help me!

0

You want to actively teleport, or move to a position? Also describe what you mean by "Wait".

0

Move to a position, by wait i mean as i said on the script i wrote, Check My Post, how if I Use Wait() goes, first goes countdown for player 1, then player2

0

You want to move one by one? If so, can you provide the table name that consists of the Players you wish to transport.

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