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