I'm trying to make a GUI that pops up when you click a part, but I don't want people to get tons of GUI's from clicking it over and over again. To fix this, I made a script which detects if the player already has the gui, but it isn't working. The script keeps coming back thinking that I still have the UI in my PlayerGui. This is the script:
local gui = script.Parent.MainframeGui
script.Parent.ClickDetector.MouseClick:Connect(function(Player)
if Player.PlayerGui:FindFirstChild("MainframeGui") == nil then
local gui = script.Parent.MainframeGui:Clone()
gui.Parent = Player.PlayerGui
gui.TimeRemaining.LocalScript.Disabled = false
else
print("Player already has the UI")
end
end)
Any help would be appreciated! Thank you, have a great day and stay healthy! :)

1 comment
I was using a LocalScripot inside of the GUI to destroy the GUI, this means it was only on the client. I ended up using a remote event from a LocalScript in the GUI to destroy it. Thank you :)