How do I know if a player's number value is higher than others? It would be nice if someone could tell me how.
Pretty short, because I actually have no idea how to compare the values.
How do I know if a player's number value is higher than others? It would be nice if someone could tell me how.
Pretty short, because I actually have no idea how to compare the values.
-- server script
local highestPlayer = nil
local function checkHighest()
local highestValue = 0
for i,v in pairs (game.Players:GetPlayers()) do --game.Players:GetPlayers() returns a table. for i,v do loops goes through that table specified in the parentheses. i is the index of the table, v is the value or in this case the player
if v.IntValue then --check if the intvalue exists in the player
if v.IntValue.Value > highestValue then --check if the value of the int value is higher than the highest value
highestValue = v.IntValue.Value --if it is, then set the highest value to the int value
highestPlayer = v.Name --and the highest player to the player
end
end
end
end
Thank you!
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
Where is the value being kept in the player?
Inside of the Player as soon as the players character loads in, should I make a folder for it instead?
You can but it's not necessary. If it's easier for you then go for it
Alright, did it. Now?