Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does my script not enable these GUI's?

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

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

2 comments

0

If you don't mind me asking, what does for 'for i,v in pairs(onJoin)do' do exactly?

0

Also, it didn't work.


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.

6 comments

0

Luckily, I don't, so I should be fine, correct?

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.

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.

0

you have to add getScripts.visible = true before the for loop. 

0

Hmm. It's not working still. Though, I am running it in Studio, admittedly. But shouldn't it still work?

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

This discussion is preserved as it was. New answers, comments, and votes are closed.