New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
1

# ClickDetector only opens GUI once when I click it...?

I would simply like the ClickDetector to open my GUI, and then the GUI can be disabled by a button. But when I try to click the ClickDetector one more time (after I closed the GUI), it doesn't work.

Part ClickDetector Code (Script):

script.Parent.ClickDetector.MouseClick:connect(function(player)
player.PlayerGui.ProductShop.Enabled = true
end)


GUI Close Button Code (LocalScript):

local s = script.Parent
s.MouseButton1Down:connect(function()
s.Parent.Parent.Enabled = false
end)


Any help would be appreciated.

0
use remote events.. i think? CjayPlyz 580 — 1y

1

ServerScripts can't look inside the PlayerGui. To open a gui in PlayerGui with a ServerScript you have to use a RemoteEvent (at least it's the only way I know). So start with adding a RemoteEvent in to ReplicatedStorage and then write this code in your ServerScript, which I believe is located in a part with a ClickDetector:

local remEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
script.Parent.ClickDetector.MouseClick:Connect(function(player)
remEvent:FireClient(player)
end)


Make a new LocalScript in the gui and write this code:

local remEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
remEvent.OnClientEvent:Connect(function()
script.Parent.Enabled = true
end)


Hope it helped!