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

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

Asked by
wjs3456 90
10 years ago

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

Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago
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.

0
As long as there is one person still wjs3456 90 — 10y
0
Just realized that I need to fix that to players. Also for testing purposes I set it to one wjs3456 90 — 10y
Ad

Answer this question