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

Trying to get the children of a child? (Not sure if makes sense)

Asked by
h19rry 20
8 years ago

I'm trying to get a script that will get the children of a folder, then get the children of what's in that folder and set the Amount.Value = 999999999 in those folders, here's what I have so far.

while true do
for i,v in pairs(game.Workspace.Tycoon3.Storage:GetChildren()) do
v:GetChildren()do
v.Amount.Value = 999999999
wait(1)
end
end
end

1 answer

Log in to vote
1
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

Find and check if the child exists, if so, set the value.

while true do
    for _, v in pairs(game.Workspace.Tycoon3.Storage:GetChildren()) do
        if v:FindFirstChild("Amount")
            v.Amount.Value = 999999999
            wait(1)
        end
    end
end

Also, with this while true do loop, you're doing the same thing over and over. If that's not what you're looking for, consider changing it. Hope this helped.

0
Worked brilliantly, just had to put a "Then" on line 4, Thankyou. h19rry 20 — 8y
0
No problem. Pyrondon 2089 — 8y
Ad

Answer this question