Adding Continue Buttons to Delete Function

I have a Delete Button that when pressed invokes a Script to delete a Pet, which works fine, however the users accidentally hit ‘x’ thinking it does something else. So now I need to add a confirmation prompt using some ‘Yes’ & ‘No’ buttons.

But the problem is I’m not sure how to break out of current function from another button script if the user chooses not to proceed. I guess I want to ‘break’ out of this function so the script doesn’t continue to execute.
(Obviously, I’m gonna invoke the buttons from this script, but do i need to create a remote function or something then validate the returned result?)

Anyway what is the best way to do this?

local deb = false
	if deb == false then
	deb = true

-- Confirm Before Delete Here

	if player:FindFirstChild("PetsEquiped") and player:FindFirstChild("Pets") and player.Pets:FindFirstChild(tostring(script.Parent.Parent)) and player.Pets[tostring(script.Parent.Parent)].Value >= 1 and script.Parent.Parent.Parent.Parent.Parent:FindFirstChild("UNE") and script.Parent.Parent.Parent.Parent.Parent.UNE:FindFirstChild("Scroll") then
		if player.PetsEquiped:FindFirstChild(tostring(script.Parent.Parent)) then		
		player:WaitForChild("Pets")[tostring(script.Parent.Parent)].Value = player:WaitForChild("Pets")[tostring(script.Parent.Parent)].Value - 1 		
	deb = false


1 Like

Personally, I’d use a BoolValue and set it’s Value true/false depending on if they choose to proceed.
Then in the other Button Script, if this Value is false then simply return.

1 Like

Ok, that totally makes sense. So I’m guessing I’d just save the BoolValue under the Local Player?

Or in the script itself.

(30 char)

I would move the code for deleting the pet inside the script that controls the confirmation dialog.

1 Like

Anywhere it’d make the job easier for you, LocalPlayer would be my choice.