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

Would this GetChildren script work?

Asked by 10 years ago
game.Players.PlayerAdded:connect(function(Player)

    function Leaderstats()
        Leaderstats = Instance.new("IntValue")
        Leaderstats.Parent = Player
        Leaderstats.Name = "Leaderstats"

        LeaderstatsChildren = Leaderstats:GetChildren()

        for LeaderstatsCount = 1, #LeaderstatsChildren do
            Leaderstats.Value = Leaderstats.Children
        end
    end

    function PowerLevel()

    end

    function Attack()

    end

    function Defense()

    end

    function Agility()

    end

    function Rank()

    end

    Leaderstats()
    PowerLevel()
    Attack()
    Defense()
    Agility()
    Rank()  

end)

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

No.


The leaderstats object's name should be "leaderstats" not "Leaderstats" (lowercase).


The Children of the new IntValue will be an empty list, since you just created it.

This means the for loop following it does not run. However, if it did run, Leaderstats.Children would result in an error, since an IntValue doesn't have a Children property.


You should also be careful, because the function Leaderstats is sharing a name with the IntValue Leaderstats. You should define it the IntValue variable as local to avoid this, and perhaps rename one of them (I would suggest making the IntValue variable lowercase)

Ad

Answer this question