I am making chances, similar to how MM2 made. This code is acting weird, like the selected player wont get selected, but the other player with no chances gets selected. And usually both players will get selected sometimes. Any ideas why this ain't working?
Code (in Script ServerScriptService):
local Chances = {}
while wait(8) do
repeat wait() until #game.Players:GetPlayers() >= 2
for _,player in pairs(game.Players:GetPlayers()) do
for i = 1,math.max(1,player.Chance.Value) do
table.insert(Chances,player.Name)
end
end
local Choice
for i,v in pairs(game.Players:GetPlayers()) do
Choice = Chances[math.random(#Chances)]
if v.Name == Choice then
v.Chance.Value = 1
warn(v.Name,"Chances:",v.Chance.Value," SHOULD be selected")
else
v.Chance.Value = v.Chance.Value + 1
warn(v.Name,"Chances:",v.Chance.Value," SHOULD NOT be selected")
end
end
end

4 comments
For what reason is it better to use :GetChildren() instead of :GetPlayers()? I personally use GetPlayers instead
GetPlayers() is better because it only gets players, -1 for false information
None of these changes make sense. While loop wih a wai in it, makes sense. But GetPlayers, I don't get at all. Plus I chose the math.random so it can choose a random player and other players have chances if that makes sense.
You don't even need a second loop. You can literally set Choice to be a random player without the second loop, then print the player's name in the given print() function.