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

Why isnt my script iterating through the players in game?

Asked by 1 year ago
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

0
on line 7 ur setting an int value to false, you cant do that. intvalues only store numbers ZeroToH3ro 82 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago

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

Ad

Answer this question