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

GUIs won't close when a click part is clicked fix?

Asked by 5 years ago

I'm creating a click part that opens a shop GUI when the player clicks it. However, there are multiple GUIs in my game and I'd like them to close if they are open when the player clicks the part. When I'm in the studio and I click the part, nothing happens. Here's my LocalScript:

01local debounce = true
02local plr = game.Players.LocalPlayer
03 
04script.Parent.Click.MouseClick:Connect(function()
05    if debounce == true then
06    plr.PlayerGui.UI.CodesGui:TweenSize(UDim2.new(0, 0, 0, 0), "Out", "Quart", 0.35)
07    plr.PlayerGui.UI.CodesGui.Visible = false
08    plr.PlayerGui.UI.ShopGui:TweenSize(UDim2.new(0, 0, 0, 0), "Out", "Quart", 0.35)
09    plr.PlayerGui.UI.ShopGui.Visible = false
10    plr.PlayerGui.UI.MenuGui:TweenSize(UDim2.new(0, 0, 0, 0), "Out", "Quart", 0.35)
11    plr.PlayerGui.UI.MenuGui.Visible = false
12    wait(0.35)
13    plr.PlayerGui.MerchantGui.Frame.Visible = true
14    plr.PlayerGui.MerchantGui.Frame:TweenSize(UDim2.new(0.295, 0, 0.496, 0), "Out", "Bounce", 0.5)
15    wait(0.5)
16    debounce = true
17    end
18end)

When I use a regular script, it works fine but the open GUIs don't close. I'm thinking that the reason is that the GUIs use LocalScripts so the regular script doesn't detect that they're open, but I could be wrong.

0
you will probably have to use RemoteEvents for this Benbebop 1049 — 5y

1 answer

Log in to vote
-1
Answered by
ryan32t 306 Moderation Voter
5 years ago
Edited 5 years ago

If a LocalScript is a Descendant of Workspace. Then it won't run any code.

A couple pictures of Gui + Explorer would be helpful. So I help you fix Opening&Closing.

0
My LocalScript is a descendant of a part. QuantumPlasmic 84 — 5y
0
Then it's not going to work. Change it to a Script. And to Define Player. Player comes as the first parameter of the MouseClick Event in ClickDetectors ryan32t 306 — 5y
0
Well, I've tried that but the GUIs don't close. QuantumPlasmic 84 — 5y
Ad

Answer this question