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

How to get the number of players that have a certain boolvalue?

``players = #game.Players:GetPlayers()

how can I change this so only if the player has a inGame score of 1 it will see the player as a player?

Inside the player I have a boolvalue named "inGame"

1 answer

Firstly you cannot make delete players. I normally use a for i,v loop for this kind of stuff. I use :GetChildren() if the instance is directly under the instance you are looping through. If it is not directly under that instance you are looping through you use :GetDescandents.The diffrence between :GetChildren() and :GetDescandents is that :GetChildren only gets the direct children under the instance, :GetDescandents loops through the children of the instance you are looping through aswell

local players = game.Players
for i,v in pairs(players:GetDescendants()) do
	if v.Name == "inGame" then -- Get the instance name what you are looking for
		-- Run code here
	end
end

2 comments

0

problem with that is 1) inGame is a vlue inside the players, not his name 2) it still doesn't count the amount of players

0

RedCommanderV2 You did not read the question correctly both your arguments are false 1. He asked quoted: "Inside the player I have a boolvalue named "inGame"" So the value is in players 2. He never asked to count the players.

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