game.Players.PlayerAdded:connect(function(player) local a = Instance.new("BoolValue") a.Name = "Playing" a.Parent = player end) for i = 1, #player do player[i].Playing.Value = true end
Is there something wrong with what I did, this isn't the entire function but this is the line where it says "Playing is not a valid member of BoolValue"
game.Players.PlayerAdded:connect(function(player) local a = Instance.new("BoolValue") a.Name = "Playing" a.Parent = player end) for i = 1, #player do player[i].Playing.Value = true end
I can't see the rest of the function and am not sure what those variables could mean, but I think I'm having a clue. This part is supposed to add a value to the player and set it true, I guess. So this would basically do it:
game.Players.PlayerAdded:connect(function(player) local a = Instance.new("BoolValue") a.Name = "Playing" a.Parent = player end) for _, randomvariablename in pairs(game.Players:GetPlayers()) do randomvariablename.Playing.Value = true end
You should be using functions, they allow easier implementation of code inside a script.
FIX :
game.Players.PlayerAdded:connect(function(player) local a = Instance.new("BoolValue") a.Name = "Playing" a.Parent = player -- Create a BoolValue and set its name and parent. end) function activate() -- Create a function for easier implementation local players = game.Players:GetChildren() for i = 1, #players do players[i].Playing.Value = true end end for i = 5, 1, -1 do -- A simple loop to call the function activate(). print(i) -- Prints a countdown from 5 to 1 wait(1) if i == 1 then -- Once the countdown ends, call activate(). print("Activated") activate() end end
As you can see, I kept your code at the top, and the loop inside the function, then used a connector to call the function. Hope this helps!