I have a script that opens up a ScreenGui from within a part. It acts as a dialog box like in an rpg. But if the part is clicked again when the dialog box is currently open, then another will show up and overlap the previous one. Is there a way to prevent this?
Here's what I have.
local waitfor = false
local waittime = 5
script.Parent.ClickDetector.MouseClick:connect(function(p)
script.Disabled = false
local t = {}
local g = script.Parent:GetChildren()
for i = 1,#g do
if g[i]:IsA("ScreenGui") then
table.insert(t,#t+1,g[i]:Clone())
end
end
for i = 1,#t do
t[i].Parent = p.PlayerGui
end
wait(3)
script.Disabled = false
if waitfor == true then
wait(waittime-3)
for i = 1,#t do
t[i]:Destroy()
end
end
end)

2 comments
It worked! Thank you so much!
No problem! Glad to help. If you need anymore help, don't be afraid to ask. You can DM me on Discord @ EdwardMacGimsey#3206 if you need anymore help I'll respond asap