Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[SOLVED] How do I detect if a player's Value is higher than the other players in the game?

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.

4 comments

0

Where is the value being kept in the player?

0

Inside of the Player as soon as the players character loads in, should I make a folder for it instead?

0

You can but it's not necessary. If it's easier for you then go for it

0

Alright, did it. Now?

1 answer

✓ Accepted answer
-- 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

1 comment

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.