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

Make everything not visible using GetChildren?

Asked by 8 years ago

I'm trying to set every frames visibility to false within a folder. The folder is located here: script.Parent.Parent.Parent

All the frames are inside this folder.

Why doesn't this work?

script.Parent.MouseButton1Down:connect(function()
        local allinfo = script.Parent.Parent.Parent:GetChildren()
        allinfo.Visible = false
end)
0
Even when changing line 3 to player.PlayerGui.allinfo.Visible = false and locating the player at the top of the code it still won't work. The errors is "allinfo is not a valid member of PlayerGui". HighValue 40 — 8y
0
While FE is enabled, scripts can't access PlayerGui. You should always use a LocalScript for gui stuff. User#11440 120 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

I think your hierarchy must be mixed up. Are you using a local script? Will this be for all players or just a few? If it is for all players, just use a normal script, cycle through the players and change the frames to visible.

If its only for select players, use a local script and change it for those selected members within there.

Hierarchy:I wouldn't access the gui by doing script.Parent.Parent.Parent ect., instead, find out where the gui is from game.Players.LocalPlayer and access it that way.

Note... If your gui is in StarterGui then is will be stored under game.Players.PlayerGui exactly as it is under StarterGui

--normal script
for _, player in ipairs(game.Players:GetChildren()) do
    frames = player.PlayerGui.PathToFrameFolderHere:GetChildren();
    for i = 1, #frames do
        frames[i].Visibility = true;
    end;
end;


--local script
condition = true; --boolean to see if you want to set frame visible for this particular player

if(condition) then
    frames = game.Players.LocalPlayer.PlayerGui.PathToFrameFolderHere:GetChildren;
    for i = 1, #frames do
        frames[i].Visibility = true;
    end;
end;
0
script.Parent.MouseButton1Down:connect(function() frames = script.Parent.Parent.Info:GetChildren for i = 1, #frames do frames[i].Visibility = true end end) --script doesn't work, and the for loop must be missing something...Right? HighValue 40 — 8y
0
There needs to be a function call on the GetChildren, and the property is Visible rather than Visibility User#6546 35 — 8y
Ad

Answer this question