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

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

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

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

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