Save selection system different output error

i got a save selection system, basically i check if the name is “Empty” if it is, it will come up with a seperate frame with a Cancel button. however, idk why but im mad struggling.?

heres my script:

-- Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

-- Variables
local deleteButton = script.Parent.SaveSelectFrame.Delete -- Reference to the Delete button
local savesFrame = script.Parent.SaveSelectFrame.Saves -- Reference to the Saves folder
local confirmationFrame = script.Parent.SaveSelectFrame.DeleteConfirmation -- Reference to the DeleteConfirmation frame
local valueObject = ReplicatedStorage:FindFirstChild("Value") -- Reference to the Value object in ReplicatedStorage
local confirmationInfo = confirmationFrame.ConfirmationInfo -- Reference to ConfirmationInfo text
local yesButton = confirmationFrame["Yes-No"].YES
local noButton = confirmationFrame["Yes-No"].NO
local cancelButton = confirmationFrame.Parent.UnableToDelete["Yes-No"].CANCEL

-- Create a blocking frame
local blockFrame = Instance.new("Frame") 
blockFrame.Size = UDim2.new(1, 0, 1, 0) -- Cover the entire screen
blockFrame.Position = UDim2.new(0, 0, 0, 0)
blockFrame.BackgroundTransparency = 1 -- Make it invisible
blockFrame.Parent = script.Parent.SaveSelectFrame -- Parent it to the main frame

-- Function to clear the save data
local function clearSaveData(saveFolder)
	if not saveFolder then 
		print("Save folder not found")
		return 
	end

	print("Save folder found:", saveFolder.Name)

	local saveMiddle = saveFolder:FindFirstChild(saveFolder.Name .. "-Middle")
	if saveMiddle then
		print("Found 'middle' frame:", saveMiddle.Name)

		for _, element in ipairs(saveMiddle:GetChildren()) do
			if element:IsA("TextLabel") then
				if element.Name == "Name" then
					print("Setting Name TextBox to 'empty'")
					element.Text = "empty"
				else
					print("Clearing text for TextBox:", element.Name)
					element.Text = ""
				end
			else
				print("Non-TextBox element found:", element.Name)
			end
		end
	else
		print("Middle frame not found for", saveFolder.Name)
	end
end

-- Function to fade in the confirmation UI
local function fadeInConfirmationUI()
	local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

	confirmationFrame.BackgroundTransparency = 1
	local frameTween = TweenService:Create(confirmationFrame, tweenInfo, {BackgroundTransparency = 0})
	frameTween:Play()

	for _, element in ipairs(confirmationFrame:GetChildren()) do
		if element:IsA("TextLabel") then
			element.TextTransparency = 1
			local textTween = TweenService:Create(element, tweenInfo, {TextTransparency = 0})
			textTween:Play()

			local stroke = element:FindFirstChild("UIStroke")
			if stroke then
				stroke.Transparency = 1
				local strokeTween = TweenService:Create(stroke, tweenInfo, {Transparency = 0})
				strokeTween:Play()
			end
		elseif element.Name == "Yes-No" then
			for _, button in ipairs(element:GetChildren()) do
				if button:IsA("TextButton") then
					-- Set buttons to fully transparent initially
					button.BackgroundTransparency = 1
					button.TextTransparency = 1

					-- Animate button to be visible
					local buttonTween = TweenService:Create(button, tweenInfo, {BackgroundTransparency = 0})
					buttonTween:Play()

					local textTween = TweenService:Create(button, tweenInfo, {TextTransparency = 0})
					textTween:Play()
				end
			end
		end
	end
end

-- Function to fade out the confirmation UI
local function fadeOutConfirmationUI(callback)
	local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

	local frameTween = TweenService:Create(confirmationFrame, tweenInfo, {BackgroundTransparency = 1})
	frameTween:Play()

	for _, element in ipairs(confirmationFrame:GetChildren()) do
		if element:IsA("TextLabel") then
			local textTween = TweenService:Create(element, tweenInfo, {TextTransparency = 1})
			textTween:Play()

			local stroke = element:FindFirstChild("UIStroke")
			if stroke then
				local strokeTween = TweenService:Create(stroke, tweenInfo, {Transparency = 1})
				strokeTween:Play()
			end
		elseif element.Name == "Yes-No" then
			for _, button in ipairs(element:GetChildren()) do
				if button:IsA("TextButton") then
					-- Animate buttons to fully transparent
					local buttonTween = TweenService:Create(button, tweenInfo, {BackgroundTransparency = 1})
					buttonTween:Play()

					local textTween = TweenService:Create(button, tweenInfo, {TextTransparency = 1})
					textTween:Play()
				end
			end
		end
	end

	frameTween.Completed:Wait() -- Wait for the frame tween to finish
	if callback then
		callback()
	end
end

-- Function to fade in the UnableToDelete UI
local function fadeInUnableToDelete()
	local unableToDeleteFrame = script.Parent.SaveSelectFrame.UnableToDelete
	local yesNoFrame = unableToDeleteFrame:FindFirstChild("Yes-No")
	local cancelButton = yesNoFrame and yesNoFrame:FindFirstChild("CANCEL") -- Correct name

	local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

	-- Ensure the frame starts fully transparent
	unableToDeleteFrame.BackgroundTransparency = 1

	-- Fade in the frame
	local frameTween = TweenService:Create(unableToDeleteFrame, tweenInfo, {BackgroundTransparency = 0})
	frameTween:Play()

	-- Fade in text labels first
	local textTweens = {}
	for _, element in ipairs(unableToDeleteFrame:GetChildren()) do
		if element:IsA("TextLabel") then
			element.TextTransparency = 1 -- Start fully transparent
			local textTween = TweenService:Create(element, tweenInfo, {TextTransparency = 0})
			table.insert(textTweens, textTween)
			textTween:Play()
		end
	end

	-- Wait for all text tweens to complete
	for _, tween in ipairs(textTweens) do
		tween.Completed:Wait()
	end

	-- Function to fade in a button
	local function fadeInButton(button)
		if button then
			button.BackgroundTransparency = 1 -- Start fully transparent
			button.TextTransparency = 1 -- Start text fully transparent

			local buttonTween = TweenService:Create(button, tweenInfo, {BackgroundTransparency = 0})
			buttonTween:Play()

			local textTween = TweenService:Create(button, tweenInfo, {TextTransparency = 0})
			textTween:Play()

			-- Optional: Wait for the button tween to complete before allowing interaction
			buttonTween.Completed:Wait()
		else
			print("Button not found!")
		end
	end

	-- Fade in the OK button
	local okButton = yesNoFrame and yesNoFrame:FindFirstChild("Ok")
	fadeInButton(okButton)

	-- Fade in the Cancel button
	if cancelButton then
		fadeInButton(cancelButton)
	else
		print("Cancel button not found!")
	end
end





-- Function to fade out the UnableToDelete UI
local function fadeOutUnableToDelete(callback)
	local unableToDeleteFrame = script.Parent.SaveSelectFrame.UnableToDelete -- Reference to the UnableToDelete frame
	local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

	-- Animate the frame to fully transparent
	local frameTween = TweenService:Create(unableToDeleteFrame, tweenInfo, {BackgroundTransparency = 1})
	frameTween:Play()

	for _, element in ipairs(unableToDeleteFrame:GetChildren()) do
		if element:IsA("TextLabel") then
			local textTween = TweenService:Create(element, tweenInfo, {TextTransparency = 1})
			textTween:Play()

			local stroke = element:FindFirstChild("UIStroke")
			if stroke then
				local strokeTween = TweenService:Create(stroke, tweenInfo, {Transparency = 1})
				strokeTween:Play()
			end
		elseif element.Name == "Ok" or element.Name == "Cancel" then
			for _, button in ipairs(element:GetChildren()) do
				if button:IsA("TextButton") then
					-- Animate buttons to fully transparent and disable interaction
					local buttonTween = TweenService:Create(button, tweenInfo, {BackgroundTransparency = 1})
					buttonTween:Play()

					local textTween = TweenService:Create(button, tweenInfo, {TextTransparency = 1})
					textTween:Play()

					-- Immediately disable button interaction when the fade-out begins
					button.Active = false -- Disable interaction during fade-out
				end
			end
		end
	end

	-- Ensure the cancelButton is treated correctly
	if cancelButton then
		local buttonTween = TweenService:Create(cancelButton, tweenInfo, {BackgroundTransparency = 1})
		buttonTween:Play()

		local textTween = TweenService:Create(cancelButton, tweenInfo, {TextTransparency = 1})
		textTween:Play()

		-- Immediately disable button interaction when the fade-out begins
		cancelButton.Active = false -- Disable interaction during fade-out
	end

	-- Call the provided callback after fade-out completes
	frameTween.Completed:Wait() -- Wait for the frame tween to finish
	if callback then
		callback()
	end
end



-- Function to handle Yes button click
local function onYesClicked()
	warn("buttony click")
	if not valueObject then 
		print("Value object not found in ReplicatedStorage")
		return 
	end

	local saveName = valueObject.Value
	print("Value found in ReplicatedStorage:", saveName)

	local saveFolder = savesFrame:FindFirstChild(saveName)
	if saveFolder then
		print("Save folder found:", saveFolder.Name)
		clearSaveData(saveFolder)
	else
		print("Save folder not found for value:", saveName)
	end

	fadeOutConfirmationUI(function()
		blockFrame.Visible = false

		-- Make ClickDetect buttons interactable again
		for _, saveMiddle in ipairs({"Save1", "Save2", "Save3"}) do
			local middleFolder = savesFrame:FindFirstChild(saveMiddle)
			if middleFolder then
				local clickDetect = middleFolder:FindFirstChild(saveMiddle .. "-Middle"):FindFirstChild("ClickDetect")
				if clickDetect then
					clickDetect.Interactable = true -- Set to interactable
					print("Enabled ClickDetect for " .. saveMiddle)
				else
					warn("ClickDetect not found in " .. saveMiddle)
				end
			else
				warn("Folder not found for " .. saveMiddle)
			end
		end
	end)
end

-- Function to handle No button click
local function onNoClicked()
	print("No button clicked. Closing confirmation frame.")
	fadeOutConfirmationUI(function()
		blockFrame.Visible = false

		-- Make ClickDetect buttons interactable again
		for _, saveMiddle in ipairs({"Save1", "Save2", "Save3"}) do
			local middleFolder = savesFrame:FindFirstChild(saveMiddle)
			if middleFolder then
				local clickDetect = middleFolder:FindFirstChild(saveMiddle .. "-Middle"):FindFirstChild("ClickDetect")
				if clickDetect then
					clickDetect.Interactable = true -- Set to interactable
					print("Enabled ClickDetect for " .. saveMiddle)
				else
					warn("ClickDetect not found in " .. saveMiddle)
				end
			else
				warn("Folder not found for " .. saveMiddle)
			end
		end
	end)
end

deleteButton.MouseButton1Click:Connect(function()
	print("Delete button clicked") -- Debug message

	-- Reference to the frames
	local unableToDeleteFrame = script.Parent.SaveSelectFrame.UnableToDelete
	local isUnableToDeleteVisible = unableToDeleteFrame.BackgroundTransparency < 1

	-- Check if confirmation frame is already open
	if confirmationFrame.BackgroundTransparency < 1 then
		-- If it's already open, fade it out and reset ClickDetect
		fadeOutConfirmationUI(function()
			confirmationFrame.BackgroundTransparency = 1 -- Set it to fully transparent
			-- Re-enable ClickDetect buttons
			for _, saveMiddle in ipairs({"Save1", "Save2", "Save3"}) do
				local middleFolder = savesFrame:FindFirstChild(saveMiddle)
				if middleFolder then
					local clickDetect = middleFolder:FindFirstChild(saveMiddle .. "-Middle"):FindFirstChild("ClickDetect")
					if clickDetect then
						clickDetect.Interactable = true -- Set to interactable
						print("Enabled ClickDetect for " .. saveMiddle)
					else
						warn("ClickDetect not found in " .. saveMiddle)
					end
				else
					warn("Folder not found for " .. saveMiddle)
				end
			end
		end)
		return
	end

	-- If UnableToDelete is visible, close it first
	if isUnableToDeleteVisible then
		fadeOutUnableToDelete(function()
			unableToDeleteFrame.BackgroundTransparency = 1 -- Set it to fully transparent
			-- Re-enable ClickDetect buttons
			for _, saveMiddle in ipairs({"Save1", "Save2", "Save3"}) do
				local middleFolder = savesFrame:FindFirstChild(saveMiddle)
				if middleFolder then
					local clickDetect = middleFolder:FindFirstChild(saveMiddle .. "-Middle"):FindFirstChild("ClickDetect")
					if clickDetect then
						clickDetect.Interactable = true -- Set to interactable
						print("Enabled ClickDetect for " .. saveMiddle)
					else
						warn("ClickDetect not found in " .. saveMiddle)
					end
				else
					warn("Folder not found for " .. saveMiddle)
				end
			end
		end)
		return
	end

	-- Set the confirmation info based on the save name
	local saveName = valueObject.Value
	print("Value found in ReplicatedStorage:", saveName)

	local saveFolder = savesFrame:FindFirstChild(saveName)
	if saveFolder then
		local saveMiddle = saveFolder:FindFirstChild(saveName .. "-Middle")
		if saveMiddle then
			local nameLabel = saveMiddle:FindFirstChild("Name")
			if nameLabel then
				if nameLabel.Text == "Empty" then
					confirmationInfo.Text = "You can't delete an empty slot!"
					print("Attempted to delete an empty slot.")

					-- Hide confirmation UI and fade in unable to delete UI
					fadeOutConfirmationUI(function()
						fadeInUnableToDelete()
					end)
				else
					confirmationInfo.Text = "You have selected the save slot for the character " .. nameLabel.Text .. " for deletion. Are you sure you want to proceed and permanently delete this slot? This action cannot be undone and all saved data for this character will be lost."
					print("Set confirmation info for valid save:", confirmationInfo.Text)

					-- Hide unable to delete UI and fade in confirmation UI
					fadeOutUnableToDelete(function()
						fadeInConfirmationUI()
					end)
				end
			else
				confirmationInfo.Text = "You have selected the save slot for " .. saveName .. "?"
				print("Name label not found, using saveName instead.")
			end
		else
			confirmationInfo.Text = "You have selected the save slot for " .. saveName .. "?"
			print("Middle frame not found, using saveName instead.")
		end
	else
		confirmationInfo.Text = "You have not selected a character slot to delete!"
		print("Set confirmation info to 'ohio' for value:", saveName)

		fadeOutConfirmationUI(function()
			fadeInUnableToDelete()
		end)
	end

	-- Make ClickDetect buttons non-interactable
	for _, saveMiddle in ipairs({"Save1", "Save2", "Save3"}) do
		local middleFolder = savesFrame:FindFirstChild(saveMiddle)
		if middleFolder then
			local clickDetect = middleFolder:FindFirstChild(saveMiddle .. "-Middle"):FindFirstChild("ClickDetect")
			if clickDetect then
				clickDetect.Interactable = false -- Set to non-interactable
				print("Disabled ClickDetect for " .. saveMiddle)
			else
				warn("ClickDetect not found in " .. saveMiddle)
			end
		else
			warn("Folder not found for " .. saveMiddle)
		end
	end

	-- Reset frames to be fully transparent before fading in
	confirmationFrame.BackgroundTransparency = 1 -- Reset to fully transparent before fading in
	fadeInConfirmationUI()


-- Connect the buttons to their respective functions
local yesButton = confirmationFrame["Yes-No"].YES
local noButton = confirmationFrame["Yes-No"].NO

yesButton.MouseButton1Click:Connect(onYesClicked)
noButton.MouseButton1Click:Connect(onNoClicked)
end)

print("Delete button script initialized")

wait(17.4)
deleteButton.Interactable = true
yesButton.Interactable = true
noButton.Interactable = true

and heres the hierachy
image

basically the error itself is just the cancel button doesnt show up.