local ClickDetector = script.Parent.ClickDetector
local GUI = game.ServerStorage.Fridge
ClickDetector.MouseClick:Connect(function(player)
if player.PlayerGui:FindFirstChild("Fridge") == nil then
GUI:Clone().Parent = player.PlayerGui
end
end)
COMMUNITY QUESTION
Why does this script work once, but then it stops working? UI won't open again after closed
1 answer
Your best option is to use RemoteEvents. I will show you how to do this.
First, insert a RemoteEvent into ReplicatedStorage, name it whatever you want.
Next, make sure you have a regular script inside of your Click Script.
And lastly, insert a LocalScript into your ScreenGUI.
Now, for the code.
Regular Script:
local remEvent = game.ReplicatedStorage:WaitForChild("RemoteEventName")
local ClickDetector = script.Parent.ClickDetector
ClickDetector.MouseClick:Connect(function(player)
remEvent:fireClient(player)
end)
Local Script:
local remEvent = game.ReplicatedStorage:WaitForChild("RemoteEventName")
local GUI = game.ServerStorage.Fridge
remEvent.OnClientEvent:Connect(function()
if script.Parent:WaitForChild("Fridge") == nil then
GUI:Clone().Parent = script.Parent
end
end)
If this is not 100% accurate, you can make some minor changes that will make it accurate. I hope this helped you!
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Idk if this will fix your issue but you can try adding a debounce to the script and also maybe do local CloneGUI = game.ReplicatedStorage.Fridge:Clone() CloneGUI.Parent = player.PlayerGui and also when you are closing the gui in the other script make sure you :Destroy() the GUI
I tried that already.
But thanks for trying to help.