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
script.Parent.MouseButton1Down:Connect(function()
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.PetsEquiped[tostring(script.Parent.Parent)]:Destroy()
end
player:WaitForChild("Pets")[tostring(script.Parent.Parent)].Value = player:WaitForChild("Pets")[tostring(script.Parent.Parent)].Value - 1
end
wait(0.5)
deb = false
end
end)
Thanks.