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

[SOLVED] Help fix this Gui?

I need help fixing a Shop Open Gui. For some reason, when I click it, it just doesn't open. Here's my Hierarchy, so you know what's going on: http://gyazo.com/94cd60bd298fe92c8add9c169725d408

And here's my code:

local ScreenGui = game.StarterGui.ScreenGui
local Button = script.Parent
local ShopBG = ScreenGui.ShopBG

function onClick()
	if ShopBG.Visible == false then
		ShopBG.Visible = true
	elseif ShopBG.Visible == true then
		ShopBG.Visible = false
	else
		print("An error has occured with the Shop Opening Script.")
	end	
end
	
Button.MouseButton1Click:connect(onClick)

3 answers

✓ Accepted answer

Here is a code that works for me every time.

function die()
script.Parent.Parent.ShopBG.Visible = true --This makes it when the open button is clicked, the frame opens. NOTICE: DO NOT PUT THE OPEN BUTTON INSIDE OF THE SHOPBG FRAME!
end

script.Parent.MouseButton1Down:connect(die)

Hope this helps! Works and tested. Also, put this code IN A REGULAR SCRIPT NOT A LOCAL ONE. If you need more help with this script, view this link: https://docs.google.com/document/d/1SBIkuy-Skuz22IOsqX2tWC45UT9rw0SrXCwlbMMKhf8/edit

2 comments

0

Thanks so much! If I could rate you up, I would. :)

0

Thanks bro glad i could help :D

You are trying to connect to a button the StarterGui. This is not the Gui players will receive in game. Put the script in the StarterGui and connect from the script's parents, locally.

Move the script to the StarterGui and replace the first line with the following:

local StarterGui = script.Parent

2 comments

0

Can you give me an example, like the code? I'm not sure how I would do what you're saying.

0

I have edited my answer to provide you with an example.

EDIT: Changed the code. I still have the same problems.

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