it doesn't pop up again after u close the gui and touch the part again and doesnt print any errors.

script:

local Detects = workspace.Detects -- Folder For All Parts That Will Be Detected By Touch
local Rep = game:GetService("ReplicatedStorage")
local UI = Rep:WaitForChild("UI") -- Folder For All UI


for i,v in pairs(Detects:GetChildren()) do
	if v:FindFirstChild("Type") then -- Detects if it is a part to be touched
		v.Touched:Connect(function(hit)
			local par = hit.Parent -- parent of hit
			local hum = par:FindFirstChild("Humanoid") -- Finds Humanoid
			if hum then
				local plr = game.Players:GetPlayerFromCharacter(par) -- Gets Player
				if plr then
					local gui = plr:WaitForChild("PlayerGui") -- Gets Gui
					if gui:FindFirstChild(v.Type.Value) then return end -- Detects if plr has gui
					local Type = v.Type -- Type Of Gui
					if UI:FindFirstChild(Type.Value) then -- Finds The Gui
						local UIC = UI[Type.Value]:Clone() -- Clones Gui
						UIC.Parent = gui -- Gives Player Gui
					end
				end
			end
		end)
	end
end

4 comments

0

When you close the GUI are you changing it to not visible? If so then your initial check ends the statement if the GUI exsists, which if you only make the frame invisible then it still exists. If im right then you could either destroy the GUI upon close or change this script to fit your needs.

0

Im deleting the gui when i close it from the players gui not the UI folder.

0

Have you tried adding in prints to figure out where it’s making it to when attempting to open 2nd time?

0

I figured you weren’t deleting your UI lol, I just wanted to confirm you were destroying the clone and not just toggling it’s visibility