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.
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.