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

Is it possible to control Math.Random?

Asked by 5 years ago

I'm making a game that involves rounds, and at the beginning of every round, a player gets a Gui shown on their screen. I'd like to know what functions/events I could use to figure out how many players are playing in the round (not in the game because some people may be waiting in the lobby) and make different GUIs pop up on different players' screens. I want to make different GUIs pop up because it tells them whether they are the killer, the cop, a citizen, or a nurse. BUT, there could only be 1 killer, 1 cop, and 1 nurse and all the rest of the players will be citizens - I'd like to know if I would use Math.Random for this part, and if I would, how would I control it so it shows different Gui's on different screens, but only 1 screen will show killer, cop, and nurse (all the rest will be citizens). Might be a little confusing because I didn't know how to word this. I'm also not asking for scripts, just looking for guidance. Thanks!

1 answer

Log in to vote
-1
Answered by 5 years ago

What you would need is a system to keep track of how many people are qualified to join the round. Then you would need to take a table of those people and do something like this,

local pos = math.random(1,#PlayersInRound)  -- Get random player

local cop = PlayersInRound[pos]

table.remove(PlayersInRound,pos)    -- Remove player so they don't become anything else

-- Do the same for other roles
0
It's not necessarily players that are qualified to join the round, its how many did join. LiLFriks 39 — 5y
Ad

Answer this question