Pet-Deletion System not working

Hello Everybody, So I have a pet inventory and I just started working on deletion for the unwanted pets that must be deleted. I have all the UI done, but when the player clicks on a pet template while having the pet deletor On. He/She should get prompted with a Frame(Which can be seen below)that asks if the player wants to complete the deletion. The issue is that the Yes and No don’t work. There seems to be no errors in the output.

Screenshot 2022-06-30 183553
Screenshot 2022-06-30 183815
LOCAL SCRIPT

local template = script.Parent
local delValue = game.Players.LocalPlayer.PlayerGui:WaitForChild("Inventory").LowerInvFrame.TextButton.delete["off/on"]
local DeleteWarn = game.Players.LocalPlayer.PlayerGui.Inventory.DeleteWarn

while wait(0.1) do 
	
	
if delValue.Value == true then 
	template.MouseButton1Click:Connect(function()
		-- warn player about deletion 
		-- figure name of pet that will be deleted so futher operatons will be achieved
		
		
		DeleteWarn.Visible = true
			
		end)
		end
	
end


local Yes  = DeleteWarn.Yes
local No = DeleteWarn.No




Yes.MouseButton1Click:Connect(function()
	template:Destroy()
	print("Successful deletion")
	
end)


No.MouseButton1Click:Connect(function()
	DeleteWarn.Visible = false
	print("NotDeleted")
end)

Is it printing either “Successful deletion” or “NotDeleted” ?

no, it does not print anything

is there a pet variable in this code, maybe then I can work on this script.

Oh I just realized you have a while loop running. It never gets to the other part of the script to connect the yes and no click functions. You should put that in a coroutine.

2 Likes