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

Random Player Chooser Script - One Chosen How To Put Them On A Team?

local t = workspace.ScreenGui.TextBox

while wait(1) do

 if t.Text == "Enough Players Needed To Play!" then

    workspace.NeedOneMorePlayers.Disabled = true

    workspace.NeedTwoMorePlayers.Disabled = true

    workspace.NeedThreeMorePlayers.Disabled = true

    workspace.NeedZeroMorePlayers.Disabled = true

    t.Text = "Game Starting Soon..."

    wait(6)

    for i = 17, 1, -1 do

        t.Text = "Intermission ("..i..")"

        wait(1)

    end
    t.Text = "Starting Game..."

    -- script.Disabled = true

    local plrs = game.Players:GetPlayers()

    local select = table.remove(plrs,math.random(#plrs))

    t.Text = "The First Seeker Will Be "..select.Name

    wait(6)

    local plrs = game.Players:GetPlayers()

    local select2 = table.remove(plrs,math.random(#plrs))

    t.Text = "The Second Seeker Will Be "..select2.Name

    wait(6)

    t.Text = "The Map Chosen Is..."

end

end

This is a random player chooser and once the script chooses a player how can you script it so that when it chooses, it puts them in the red team?

1 comment

0

Please do NOT duplicate questions. Sure people may not answer but that doesn't give you or anyone else the right to spam scripting helpers with questions that no one will answer.

1 answer

First of all, define two values and make them equal to your teams in your game.Teams folder. Then, you can change chosen players' team color to primary team by using Player.TeamColor = BlueTeam.TeamColor, and then do the same thing for second one. Player.TeamColor = RedTeam.TeamColor

RedTeam = game.Teams.RedTeam
BlueTeam = game.Teams.BlueTeam

AllPlayers = game.Players:GetChildren()
ChosenOne = AllPlayers[math.random(#AllPlayers)]
ChosenTwo = nil
while ChosenTwo == nil then --To make sure ChosenTwo is not equal to nil
	ChosenTwo = AllPlayers[math.random(#AllPlayers)]
	while ChosenTwo == ChosenOne --To make sure ChosenTwo is not equal to ChosenOne
		ChosenTwo = AllPlayers[math.random(#AllPlayers)]
	end
end

By the way, if you want to choose some random variable from a table, do it by ChosenOne = TableName[math.random(#TableName)], fix it.

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