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

How to make this script randomly select someone to be it?

I want to make it so that when a new game starts 15 seconds in a person will be randomly selected to be it which will make them be on the orange team. Very much like a hide and seek script. Here's the script.

function FirstInfected()
Wait(15)
players=game.Players:GetPlayers()
while player==1 do
	first_infected=players[math.random(1, #players)]
	first_infected.TeamColor=Brick.new("Bright orange")
end
end

FirstInfected()

Thanks

1 answer

function FirstInfected()
wait(15) --Lua is case sensitive, so Wait is not recognized, lowercase it.
players=game.Players:GetPlayers()
while player==1 do --Could you explain this line? I am confused on when player came from, and why you just want one.
    first_infected=players[math.random(1, #players)]
    first_infected.TeamColor=BrickColor.new("Bright orange") --It's BrickColor, not Brick. Brick I don't even know what that is.
end
end

FirstInfected() --Alright, it executes the script.

If you could just explain line four for me, I could probably help you out further.

2 comments

0

As long as there is one person still

0

Just realized that I need to fix that to players. Also for testing purposes I set it to one

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