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

GUI not visible even when Visible is true?

I’m making a shop button that: If the shop is open, it closes the shop when you click it, and vice versa. But the issue is when I click it the Visible property gets checked but the GUI doesn’t show.

3 comments

0

If you are changing the visibility property, are you doing it through the player's PlayerGui or StarterGui?

0

StarterGui

0

(I think)

2 answers

If you happen to be changing the visibility property through StarterGui, then it is a pretty common mistake. Whenever you run your game, all the content in StarterGui gets replicated and put into the player's PlayerGui. So for instance if you wanted to change a certain property of a GUI while the game is still running, you would have to change it via PlayerGui, but this is just the case if you do not put your local scripts inside the certain GUI's.

EXAMPLE:

local player = game.Players.LocalPlayer
local myButton = player.PlayerGui.ScreenGui.TextButton

myButton.MouseButton1Click:Connect(function()
	--Something happens when clicked--
end)

2 comments

0

doesnt work, heres my code

0

??????? forgot to actually paste it: local player = game.Players.LocalPlayer local shop = player.PlayerGui.shopGui.Frame shop.MouseButton1Click:Connect(function() if shop.visible == false then shop.Visible = true else shop.Visible = false end end)

Here is an example of what you could do using a local script in StarterGui

--Open script This will of course need the UI under properties Visible to false

local myButton = script.Parent.TextButton
local Frame = script.Parent.Parent.Frame

myButton.MouseButton1Click:Connect(function()
	Frame.Visible = true
end)

--Close Script This will of course need the UI under properties Visible to true

local myButton = script.Parent.TextButton
local Frame = script.Parent.Parent.Frame

myButton.MouseButton1Click:Connect(function()
	Frame.Visible = false
end)

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