Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

1 comment

0

you will probably have to use RemoteEvents for this

1 answer

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.

3 comments

0

My LocalScript is a descendant of a part.

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

0

Well, I've tried that but the GUIs don't close.

This discussion is preserved as it was. New answers, comments, and votes are closed.