I have been trying to make a script which, basically starts from a specific minimum value to maximum value, according to how much amount of players are in the game.
Example, if there is 1 in a 10 max players, it would start with 2000 initial minimum value and the maximum value would be 4000. More players joining, the more it will increase until it reaches the maximum value, if the server is at max players (10/10) the value would be 4000 max.
And for that, i’ve tried to script something like this without really knowing if, it should be used a math.clamp for this, or not.
local CalculatedValue = StartingValue * (MaxPlayers/Players) * MaximumValue
I’ve tried many other ways using that same way, and it is making me have some headache to figure out how to do that, as i’ve took like, almost 1 hour for that, and still haven’t found out
how to do that.
Any help would be appreciated of how to do that. Thanks.
Can I see the part of the script where you’re trying to do this? In the image, you’re getting the right value, but you aren’t adding it to the existing Minimum value (not sure if this is on purpose or not, please correct me if it is.)
I found it by myself based on your script, since it wasn’t working still, so i had a brilliant idea from your script which it worked precisely perfect.
Basically i had the idea to just put the starting initial value from your script as MaxValue-MinValue. And then get this subtracted calculated value and, put it as under dependent from amount of Players with MaxPlayers from initial 0 to subtracted calculated value. And so subtracting the MinValue initial, with the subtracted calculated value dependent from amount of Players with MaxPlayers.
And so it gave me a very precise result of what i really wanted.
local SubtractedValue = MaxValue-MinValue
local SubtractedValueEstimatedPlayers = (Players/MaxPlayers) * SubtractedValue
local FinalValueEstimated = MinValue+SubtractedValueEstimatedPlayers
print(math.floor(FinalValueEstimated))
But well, thank you for your help, i will be marking your script post as Solution. as it can be used for a hint of how something like that does works.