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

Why isnt my script iterating through the players in game?

local playerService = game:GetService("Players")
local players = playerService:GetPlayers()

for _, player in pairs(players) do
	local int = Instance.new("IntValue")
	int.Name = "playersLeft"
	int.Value = false
	int.Parent = player
	print("playersFound")
end

and my script is in serverScriptService

1 comment

0

on line 7 ur setting an int value to false, you cant do that. intvalues only store numbers

1 answer

This simple script will go through all players and adds a bool value to each player

local playerService = game:GetService("Players")
local players = playerService:GetChildren()

for _, player in pairs(players) do
    local bool = Instance.new("BoolValue")
    bool.Name = "playersLeft"
    bool.Value = false
    bool.Parent = player
end

you can check if the script works by going in players and see if there is a bool value called playersLeft. Hope this helps

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