How doi make a character gui visible and not visible

I think my pc is cursed, or maybe its the game idk, nothing is working :cryemotes:
https://gyazo.com/d3ad69550d8eed7f78e66dd8ec89fb55

2 Likes

Soo before the textbutton was outside of the GUI and then it was inside the GUI and now itā€™s inside the frame. After every solution Iā€™m giving you, youā€™re changing the hierarchical order so that the variables arenā€™t properly indexing the components. Iā€™m not sure how to help you anymore, sorryā€¦

4 Likes

Hello, there is an error with the script you wrote.

 local GUI= CharSelectShop
game.Players.LocalPlayer.Player.Gui.CharSelectShop -- Also what's with this line exactly? Fix it or remove maybe...
local Button = TextButton

locaal function Toggle()
	if CharSelectShop and TextButton then
		GUI.Visible ==true -- == is used on if statements
		GUI.Visible = false -- You are making it invisibile again.
	else
			GUI.Visible = true
	end
end

TextButton.MouseButton1Down:Connect(Toggle)

To fix this, hereā€™s the correct script:

local CharSelectShop = game.Players.LocalPlayer.Player.Gui.CharSelectShop -- I tried fixing it for you to match this script.
 local GUI = CharSelectShop

local Button = TextButton

locaal function Toggle()
	if CharSelectShop and TextButton and GUI.Visible == false then -- You wanna check if the GUI is already visible
		GUI.Visible = true -- now it's only 
	else
			GUI.Visible = false
	end
end

TextButton.MouseButton1Down:Connect(Toggle)
3 Likes

I would say that

local function Toggle()

would be right :slight_smile:

2 Likes
script.Parent.Parent = script.Parent.Parent.Parent--?
script.Parent.Position = Udim2.new()-- Usually, when you change an GUI's parent, they go to an random position, so put here the Udim2 you want.

local Button = script.Parent--Variable of the Button.
local Frame = Button.Parent:WaitForChild("Container")--Variable of the Frame(Container)

Button.MouseButton1Click:Connect(function()
    Frame.Visible = not Frame.Visible--Makes the boolean property of the frame(Visible), the reverse of what it currently is.
end)

If you didnā€™t understand, donā€™t hesitate on direct messaging me here on the forum.
If you guys noticed an error, then i will edit the code to fix it.

About Udim2

1 Like

If you put the textbutton in the screengui and not the frame, the code DaCrazyDev gave you should work.

1 Like

I vouch for you bro! It works and its extremely helpful

ll give you coins in the game whenever its released as a added bonus