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 button script that puts you in a random team?

I don't want it to be a choose your team thing i just want it so when they walk on the button the go to a random team. I think it goes like this...

local t1 = script.Parent.Parent.Parent.Teams.TeamColor = Brick.new("Bright blue")
local t2 = script.Parent.Parent.Parent.Teams.TeamColor = Brick.new("Really red")
local teams = t1.. t2
function ontouch(part)
local h = game.Player:GetPlayerFromCharacter(part.Parent)
if h ~= nil then
h.TeamColor.new = teams
end
end

1 answer

✓ Accepted answer
teams = {"Bright blue", "Really red"} --Add more brick colors here for more teams.
script.Parent.Touched:connect(function()
local plyr = game.Players:GetPlayerFromCharacter(part.Parent) --You said game.Player
if plyr then
plyr.TeamColor = teams[math.random(1,#teams)]
end
end)

Use a table and math.random. This is the whole script. You can add more teams.

Tables and math.random

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