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

How do I make it so my GUIs enable whenever I call it in a script?

Asked by 5 years ago

Hey everyone. It's been a minute since I've coded in roblox studio. I'm trying to make it so a GUI enables and disables on the click of another button but it is failing to work for a reason completely unknown to me. Here is the code:

01local button = script.Parent.ImageButton
02local debounce = false
03local browseBuyGUI = game.StarterGui.BrowseBuyGUI
04local teleGUI = game.StarterGui.TeleportingToDealership
05local function onButtonActivated()
06    if debounce == false then
07        if browseBuyGUI.Enabled == true then
08            browseBuyGUI.Enabled = false
09            teleGUI.Enabled = false
10        else
11            browseBuyGUI.Enabled = true
12            teleGUI.Enabled = true
13        end
14        debounce = true
15        wait(0.5)
16        debounce = false
17    end
18end
19 
20button.Activated:Connect(onButtonActivated)

I have another script set to enable a blur effect whenever the browseBuyGUI is activated, and that works fine. The blur effect appears, but the GUI does not. This is a local script. Here is a picture of the hierarchy. (This same problem also happens with the teleGUI) Any help is appreciated, thanks.

0
Is this a tool? Why are you using activated. Thats a value on tools. voidofdeathfire 148 — 5y
0
don't use StarterGui the StarterGui is not for player, use PlayerGui example, game.Players.LocalPlayer.PlayerGui G2001H 75 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago

Maybe try using mouse button up and then call the gui when mouse button is up, and then just set the property of the gui in your script to visible or enabled?

0
This doesn't work. Mainly because mousebutton1up is different from mousebutton1down. Mousebutton1up is on release and mousebutton1down is when its clicked. voidofdeathfire 148 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
01local button = script.Parent.ImageButton
02local debounce = false
03local browseBuyGUI = game.StarterGui.BrowseBuyGUI
04local teleGUI = game.StarterGui.TeleportingToDealership
05local function onButtonActivated()
06    if debounce == false then
07        if browseBuyGUI.Enabled == true then
08            browseBuyGUI.Enabled = false
09            teleGUI.Enabled = false
10        else
11            browseBuyGUI.Enabled = true
12            teleGUI.Enabled = true
13        end
14        debounce = true
15        wait(0.5)
16        debounce = false
17    end
18end
19 
20button.MouseButton1Down:Connect(onButtonActivated)
Log in to vote
0
Answered by
G2001H 75
5 years ago

Don't use 'StarterGui' because its not valid member of player, use 'PlayerGui' Here is the right script:

01local player = game.Players.LocalPlayer
02local button = script.Parent.ImageButton
03local debounce = true
04local browseBuyGUI = player.PlayerGui.BrowseBuyGUI
05local teleGUI = player.PlayerGui.TeleportingToDealership
06 
07function onButtonActivated()
08    if debounce == false then
09        if browseBuyGUI.Enabled == true then
10            browseBuyGUI.Enabled = false
11            teleGUI.Enabled = false
12        else
13            browseBuyGUI.Enabled = true
14            teleGUI.Enabled = true
15            end
View all 22 lines...

Answer this question