I still don't know how to use variables in a screen gui

(its my first few days of scripting)
So im really embarrassed that I don’t know how to do this yet… but I’ve been coding on my computer straight for 12 hours and I’ve browsed so many areas but I can’t seem to even find out how to use variables with a screen gui.

local button = script.Parent
local starterGui = game:GetService("StarterGui")
local visible = true
local button2 = 
local invisible = false

function newgui()
	wait(0.03) 
	button.Visible = invisible 
	button2.Visible = visible 

end

button.MouseButton1Click:Connect(newgui)

The button2 variable is empty.

Screen Shot 2023-08-04 at 11.16.13 AM

im prob gonna get replied the most basic line of code but please don’t bully me

4 Likes

By leaving = empty your going to get errors

Also can you expand on what your trying to do?

I know it sounds stupid but I need to make a variable (which is why there is local button2
)

I just need it to react to button2.Visible = visible

Here are some minor fixes. Can you expand on what you’re trying to do like trying to open a frame when you click the button or something??

local button = script.Parent.TextButton
local starterGui = game:GetService("StarterGui")--I don't think you'll need this line
local visible = true 
local button2 = false--You can make button2 false and change it to true 
local invisible = false

function newgui()
	wait(0.03) 
	button.Visible = invisible 
	button2.Visible = visible --button2 doesn't exist in the explorer this would be an error you could do button2 = true

end

button.MouseButton1Click:Connect(newgui)

Basically im trying to mess around with opening/closing buttons and frames


When red button pressed, Red disappears and green disappears. However, green does not

Also if you want an empty varible do this

local button2

instead of button 2

button2.Visible = visible-- remove this

and do this

script.Parent.Parent.Frame2.Visible = false–change frame2 if green box is not frame2

I’m confused, button2 is an empty variable? How would you get that to react to anything?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.