Deleting a cloned GUI from parent

So the only issue im having with my code is that its not deleting the cloned GUI from the players parent.

Could someone help me fix this issue?

Code:

WarnEvent.OnServerEvent:Connect(function(player, WarnPlayer)
	local PlayerWarn = game.Players:FindFirstChild(WarnPlayer)
	if admins[player.Name] and PlayerWarn then
		local noti = game:GetService("ReplicatedStorage").Notification
		noti:Clone().Parent = PlayerWarn.PlayerGui
		wait(6)
		noti.PlayerWarn.PlayerGui:Destroy()
		
		
	end
end)

Maybe you do it like that, then it should work.

local noti = game:GetService("ReplicatedStorage").Notification:Clone()
noti.Parent = PlayerWarn.PlayerGui
wait(6)
noti.PlayerWarn.PlayerGui:Destroy()

Basically there was no reference to the clone you tried to destroy just to the template you cloned.

1 Like

Wait nevermind. Your code works. I just had to change it to noti:Destroy()

Ok I was already wondering what you try to destroy.

1 Like