How could I go about deleting the cloned gui created from this script with an event

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if plr then
			if not plr.PlayerGui:FindFirstChild("GUIClonedfromtouchblock") then
				local clonedgui = script.Parent:FindFirstChildOfClass("ScreenGui"):Clone()
				clonedgui.Name = "GUIClonedfromtouchblock"
				clonedgui.Parent = plr.PlayerGui
				script.Parent.TouchEnded:Connect(function(hit2)
					if hit == hit2 then
						game.Debris:AddItem(clonedgui,0)
					end
				end)
			end
		end
	end
end)

Depends when you want to delete the clone. A simple :Destroy function should work, and you can do it in a localscript. I might be missing something seeing as this answer is pretty obvious, in which case please let me know.

Right, sorry I forgot to specify. I would want it to delete when a remote event is fired, but I’m not too familiar with clones so I was wondering if that’s something you have to keep inside the function?

If you have a variable for the clone, you can just state the variable followed by the :Destroy() function

:Destory() wouldn’t be necassary when they already used debris service

image