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

not a valid member of BoolValue?

Asked by 9 years ago
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"

2 answers

Log in to vote
0
Answered by
Wutras 294 Moderation Voter
9 years ago
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
Ad
Log in to vote
0
Answered by 9 years ago

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!

Answer this question