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

How do I check to see if all players have a certain leaderstat value?

Asked by 3 years ago

I'm trying to create a simple game, but need to check if all the players have a certain value in their leaderstat. How do I do it?

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Insert a Server Script (Normal Script) anywhere you want and write the following:

local Certain_Value = _______ --Show the leaderstat value whether a number or a string. Example: 1, 11, 21

local Stats_Name = _______ --The name of the stat which you want to check. Example: Coins or Gold

for _, Player in pairs(game.Players:GetChildren()) do --This will check all players
    local leaderstats = Player:WaitForChild("leaderstats") --Getting leaderstats
    local RStat = leaderstats:WaitForChild(Stat) - the stat of player

    if RStat.Value == Certain_Value then --if the stat is certain value, then

        --Write what you want to do to the player here.

    end
end
Ad

Answer this question