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

How do I make a button script that puts you in a random team?

Asked by
duckyo01 120
9 years ago

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

Log in to vote
1
Answered by 9 years ago
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

Ad

Answer this question