I only know that i should use
for i = 1, #game.Players:GetChildren()
right? then i have no idea what should i do
I only know that i should use
for i = 1, #game.Players:GetChildren()
right? then i have no idea what should i do
To check which player’s BoolValue value is true, you need to add a conditional statement within the for loop that checks each player’s BoolValue. Here’s an example code:
for i = 1, #game.Players:GetChildren() do
local player = game.Players:GetChildren()[i]
if player:FindFirstChild("BoolValue") and player.BoolValue.Value == true then
print(player.Name .. "'s BoolValue is true!")
end
end
This code loops through all the players in the game, and for each player, it checks if they have a BoolValue and if its value is true. If the player’s BoolValue is true, it will print out their name and a message indicating that their BoolValue is true.
Note: I would recommend to replace Players:GetChildren()
with Players:GetPlayers()
.
Players:GetPlayers()
returns a list of all currently connected players in the game, as instances of the Player
class. This method automatically filters out any non-player instances, such as GUI elements or other objects that may be in the Players
container.
Players:GetChildren()
returns a list of all children of the Players
service, including both player and non-player instances. This method does not filter out non-player instances and returns all children of the Players
service, regardless of their type.
i dont know but that doesnt work even though i changed getchildren to getplayers
You can try using a for loop with pairs instead
Like:
for index, player in pairs(game:GetService("Players"):GetPlayers()) do
if player:FindFirstChild("Your BoolValue's Name", true).Value == true then
print("The player's BoolVaue is true!")
end
end
not working…
…
I am unable to assist you since you didn’t provide more information.
If you show me the script I’ll be able to debug it.
for i = 1, #game.Players:GetPlayers() do
local player = game.Players:GetPlayers()[i]
local tagger = player:FindFirstChild("tagger")
if tagger and tagger.Value == true then
print(player.Name .. "'s BoolValue is true!")
end
end
Make sure that tagger
exists before running that code.
I am not sure when you created it, but it is not included in the script.
Edit: No need for this comment since you updated your code.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.