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

check all children then if there isn't a name, adding it help?

Asked by
NotSoNorm 777 Moderation Voter
8 years ago

So pretty much, there is a stringvalue added into the script, but it keeps adding multiple people into the script even if they're already in. I'm trying to stop this by checking to see if the players name is already in the children and if it's not then adding it. How?

local playersingame = {}
    for i = 1, #script:GetChildren()do
        table.insert(playersingame, script:GetChildren()[i].Name)
    end
    local plrnum = 1
    for i = 1,#playersingame do
        plrnum = plrnum + 1
        if not child == playersingame[plrnum] then 
            local a = Instance.new("StringValue",script)
            a.Name = child
            a.Value = child
        end
    end
end

Answer this question