Ok, this is sort of a dilemma for me. I've been searching through formulas and looking everywhere I can but I just can't seem to find an answer. So basically, I'm looping through all the players, and each player gets a random number. Sounds cool, ok.
Now, thats fine and all, but the dilemma comes in when the sum of all the player's number must equal a specific number.
Let use "I" to represent the amount of players in our for loop.
Lets say: Xx_FROSBITExX gets the number 25 and SomeOtherDude gets the number 50.
Now this is intended behaviour of math.random(x,y). But, is it possible for our numbers to add to 100. So If there 5 players. The sum of all 5 random numbers equals 100.
This may be represented by: 15, 25, 20, 35, 5. Notice how the 5 numbers (each player's random number adds to 100).
My script right now:
local totalweight = 100 local min = 1 local table = {} local NumOfPlr game.Players.PlayerAdded:Connect(function(player) for i, plr in pairs(game.Players:GetPlayers()) do NumOfPlr = i table[plr] = ...how the heck can I figure this out end end)