Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited 3 years ago

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.

0
Where is the value being kept in the player? LeedleLeeRocket 1257 — 3y
0
Inside of the Player as soon as the players character loads in, should I make a folder for it instead? CoolBlueJay000 48 — 3y
0
You can but it's not necessary. If it's easier for you then go for it LeedleLeeRocket 1257 — 3y
0
Alright, did it. Now? CoolBlueJay000 48 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
-- 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
0
Thank you! CoolBlueJay000 48 — 3y
Ad

Answer this question