Gui Remaining visible despite conditions not intending to

So I am aware of RunService but it runs too fast to keep up (Or such). The Gui stays visible despite the conditions false.
This script is itself, nothing else is above or below it.
Code:

local MessageOn = false
local CanMessageOn = game.ServerStorage.Power.Gui.CanMessageOn
local MessageOff = false
local CanMessageOff = game.ServerStorage.Power.Gui.CanMessageOff
local DB = false
local PlayerWhoRestored = game.ServerStorage.Power.Gui.PersonWhoRestored

while task.wait(1) do
	--On
	if DB == false and CanMessageOn.Value == true then
		DB = true
		CanMessageOn.Value = false
		script.Parent.MessageOn.OutageText.Text = "RESTORED BY "..PlayerWhoRestored.Value.Name
		script.Parent.MessageOn.Visible = true
		task.wait(3)
		script.Parent.MessageOn.Visible = false
		DB = false
	end
	--Off
	if DB == false and CanMessageOff.Value == true then
		DB = true
		CanMessageOff.Value = false
		script.Parent.MessageOff.Visible = true
		task.wait(3)
		script.Parent.MessageOff.Visible = false
		DB = false
	end
end

This code part is local script?

No. A script inside the Gui. The issue is it runs the Off if statment even tho its false.

Turns out I accidently put the PowerOff.Value = true in a while loop. My bad. Thanks for helping tho!