Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] Help fix this Gui?

Asked by 10 years ago

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

Log in to vote
0
Answered by 10 years ago

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

0
Thanks so much! If I could rate you up, I would. :) SlickPwner 534 — 10y
0
Thanks bro glad i could help :D PyccknnXakep 1225 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

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
0
Can you give me an example, like the code? I'm not sure how I would do what you're saying. SlickPwner 534 — 10y
0
I have edited my answer to provide you with an example. Drak0Master 172 — 10y
Log in to vote
0
Answered by 10 years ago

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

Answer this question