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:

local debounce = true
local plr = game.Players.LocalPlayer

script.Parent.Click.MouseClick:Connect(function()
    if debounce == true then
    plr.PlayerGui.UI.CodesGui:TweenSize(UDim2.new(0, 0, 0, 0), "Out", "Quart", 0.35)
    plr.PlayerGui.UI.CodesGui.Visible = false
    plr.PlayerGui.UI.ShopGui:TweenSize(UDim2.new(0, 0, 0, 0), "Out", "Quart", 0.35)
    plr.PlayerGui.UI.ShopGui.Visible = false
    plr.PlayerGui.UI.MenuGui:TweenSize(UDim2.new(0, 0, 0, 0), "Out", "Quart", 0.35)
    plr.PlayerGui.UI.MenuGui.Visible = false
    wait(0.35)
    plr.PlayerGui.MerchantGui.Frame.Visible = true
    plr.PlayerGui.MerchantGui.Frame:TweenSize(UDim2.new(0.295, 0, 0.496, 0), "Out", "Bounce", 0.5)
    wait(0.5)
    debounce = true
    end
end)

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