Night Vision Thing Won't Work

So I’ve got this night vision goggle tool. it works fine when i put it in the starterpack, but when i put it into my custom gadget giver, it just starts to make the tool an automatic strobe light. So my fix was to have that local script just enable the night vision effect, while the main script turns the “enable” value off and turns the effect off. Except that doesn’t work. So I need some help. I want to either fixing this strobe light effect, or make the line of code that turns off the effect work.

LocalScript:

function check()
	while wait(0.25) do
		if script.Parent.Equip.Value == true then
			game.Lighting.NightVision.Enabled = true
			
			game.Lighting.GlobalShadows = false
		else
			game.Lighting.NightVision.Enabled = false
			
			game.Lighting.GlobalShadows = true
		end
	end
end

check()

Main Script code:

cooldown = 2			
name = "Night Vision"		


equip = script.Parent.Equip				
deb = true								
sound = script.Parent.Handle.Equip		
tool = script.Parent					


function onActivated()
	if equip.Value ~= true and deb then
		
		deb = false
		
		NV = Instance.new("Hat")
		NV.Parent = script.Parent.Parent
		NV.Name = name
		
		
		script.Parent.Handle:Clone().Parent = NV
		NV.AttachmentPos=Vector3.new(0,0.3,0)
		script.Parent.Handle.Transparency = 1
		
		
		
		
		
		equip.Value = true
		sound:Play()
		
		wait(cooldown)
		deb = true
		
	elseif equip.Value and deb then
		
		deb = false
		
		NV:Destroy()
		game.Lighting.NightVision.Enabled = false
		script.Parent.Handle.Transparency = 0
		game.Lighting.NightVision.Enabled = false
		
		
		
		
		equip.Value = false
		wait(cooldown)
		deb = true
		
	end
end

script.Parent.Activated:Connect(onActivated)

There’s not enough context here. What about your script doesn’t work and are you able to pinpoint where the issue happens in your code? What steps do you commit to before the issue occurs? Is there anything in your console? What debugging have you done so far? Please supply context.

Besides lack of context, there are some particularly wrong-seeming choices and other nitpicks I have about the code I’d like to note: