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

Why does my script not enable these GUI's?

Asked by 8 years ago

Hi there, I've been having trouble with my script. (naturally)

What I'm trying to do is make it so my script will enable all the of GUI;

-alterme (regular ScreenGui) -Frames (Frame) - face (picture) - warning (picture) - text1 - text2 - text3

but when I run the script, it goes through without error, but does absolutely nothing in the process.

Script:

getScripts = script.Parent.alterMe

local onJoin = getScripts:GetChildren()

for i = 1, #onJoin do
    visible = true
end

I've been at this all day and quite frankly this 7 line script has given me a real bad headache. Any help would be appreciated at this point. :)

2 answers

Log in to vote
0
Answered by
WVPII 5
8 years ago

getScripts = script.Parent.alterMe

local onJoin = getScripts:GetChildren()

for i = 1, #onJoin do visible = true end

getScripts = script.Parent.alterMe

local onJoin = getScripts:GetChildren()

for i,v in pairs(onJoin)do
    visible = true
end
0
If you don't mind me asking, what does for 'for i,v in pairs(onJoin)do' do exactly? Dronaman 5 — 8y
0
Also, it didn't work. Dronaman 5 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

local getScripts = script.Parent.alterMe local onJoin = getScripts:GetChildren() for index, value in pairs(onJoin) do value.visible = true end

in pairs(tablename) iterates through the table 'tablename' at each index 'index' and returns the value at each index. In your case, the values would be everything inside the table 'onJoin'. However if you have an object inside of alterMe that doesn't have a 'Visible' property, an error will be thrown.

0
Luckily, I don't, so I should be fine, correct? Dronaman 5 — 8y
0
SHOULD be, but it's good programming practice to catch for any future errors. You could add a simple check in side the for loop. something like, if value:IsA("GuiBase") then value.visible = true end.  GuiBase is the class that encompasses all GUI elements.  Similar to BasePart for any kind of brick. SirQuixotic 0 — 8y
0
Alright, the code that you sent me didn't work, which it should, but this also means that when I enable alterMe, I also want to enable the other resources inside of alterMe. Dronaman 5 — 8y
0
you have to add getScripts.visible = true before the for loop.  SirQuixotic 0 — 8y
View all comments (2 more)
0
Hmm. It's not working still. Though, I am running it in Studio, admittedly. But shouldn't it still work? Dronaman 5 — 8y
0
it worked for me on my test imagebutton. Make sure you're doing the f5 run and not the play that doesn't spawn a player SirQuixotic 0 — 8y

Answer this question