I have a logic problem?
So basically, all i want to do is, look through the length f the players, and then one of those players are Class1, then we get another random player, this time the player is Class 2, the rest of the players which aren't any of the two are Class3. So 1 player is Class1 another("Different") player is Class2 and the rest are basically Class3.
I then want that value signaled back to the script this is called in, so that i can determine which of the players(That i iterate over once again) are class1, class2 and the rest which are classified as class3, then i show them a display based on that. (Sorry for long explanation!)
Thanks in advance!
This is what i got:
01 | local ClassManager = { } |
03 | local rndm = math.random() |
05 | local classes = { murder, sheriff, inno } |
07 | local class = classes [ math.random( 1 ,#classes) ] |
09 | function ClassManager:DisplayClass() |
10 | for i,v in pairs (game.Players:GetPlayers()) do |
11 | local gui = v.PlayerGui:FindFirstChild( "ScreenGui" ) |
12 | local class 1 disp = gui:FindFirstChild( "ClassDisplayiNormal" ) |
13 | local class 2 disp = gui:FindFirstChild( "ClassDisplayArmed" ) |
14 | local class 3 disp = gui:FindFirstChild( "ClassDisplayInnocent" ) |
15 | local class 1 = v [ math.random( 1 ,#v) ] |
16 | local rndPlr = v [ math.random( 1 ,#v) ] |
17 | if rndPlr = = class 1 then repeat |
18 | rndPlr = v [ math.random( 1 ,#v) ] |
19 | until rndPlr ~ = class 1 |
21 | if class = = classes [ 1 ] then |
24 | elseif class = = classes [ 2 ] then |
26 | class 2 disp.Visible = true |
The thing is, it always shows the class1 display regardless. Anybody, please help!
And as an side note, i call this in an Module script that is then called in an Normal Server Script,
They are all inside ServerScriptService.