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

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

Asked by 6 years ago

``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

Log in to vote
0
Answered by 6 years ago

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
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 User#20388 0 — 6y
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. Ernie252 -4 — 6y
Ad

Answer this question