Very annoyed at this error. Someone please help

--//CODE FOR THE SETTINGS BUTTON
Lighting = game.Lighting

Button = script.Parent

Button.MouseButton1Click:Connect(function()

script.Parent.Parent.Parent.SettingsFrame.Visible = not script.Parent.Parent.Parent.SettingsFrame.Visible

warn(script.Parent.Parent.Parent.SettingsFrame.Visible)

Lighting.Blur.Enabled = not Lighting.Blur.Enabled

end)

It literally returns “false” each time for no reason.

i think the error starts from the SettingsFrame not visible so
if script.Parent.Parent.Parent.SettingsFrame is a screengui, then replace

script.Parent.Parent.Parent.SettingsFrame.Visible = not script.Parent.Parent.Parent.SettingsFrame.Visible

into

script.Parent.Parent.Parent.SettingsFrame.Enabled = not script.Parent.Parent.Parent.SettingsFrame.Enabled

if it’s not a screengui but a canvansgui, do this instead

if script.Parent.Parent.Parent.SettingsFrame.Visible = false then
  script.Parent.Parent.Parent.SettingsFrame.Visible = true
else
  script.Parent.Parent.Parent.SettingsFrame.Visible = false
end

That wont work.

Fixed it, it was because i was handing both in the same script, so i slapped another localscript in there and fixed it. Thanks!