What's wrong with this code?

I’m almost done with a script, but I have one problem, one line has an error, can anyone help?
Script:
local Website = script.Parent.Parent.Parent
local player = game.Players.LocalPlayer
local Create = script.Parent.Parent.Parent.Create
local Friends = script.Parent.Parent.Parent.Friends local Games = script.Parent.Parent.Parent.Games local Home = script.Parent.Parent.Parent.Home local Settings = script.Parent.Parent.Parent.Settings

script.parent.MouseButton1Click:Connect(function()

  if script.Parent.Parent.Parent.DarkMode.Value == false then
    wait (0.1)
    Create.BackgroundColor3 = Color3.fromRGB(6, 5, 34)
    Friends.BackgroundColor3 = Color3.fromRGB(6, 5, 34)
    Games.BackgroundColor3 = Color3.fromRGB(6, 5, 34)
    Home.BackgroundColor3 = Color3.fromRGB(6, 5, 34)
    Settings.BackgroundColor3 = Color3.fromRGB(6, 5, 34)
    script.Parent.Parent.Parent.DarkMode.Value = true
  else
    script.Parent.Text = "Light Mode"
    wait (0.1)
    Create.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    Friends.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    Games.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    Home.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    Settings.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    script.Parent.Parent.Parent.DarkMode.Value = false
  end
end)

I’m not fully sure but I think it’s just the P on parent in line one not being capatalized, if it’s not this could you please let me know the error?

script.Parent.MouseButton1Click:Connect(function()
  if script.Parent.Parent.Parent.DarkMode.Value == false then
    wait (0.1)
    Create.BackgroundColor3 = Color3.fromRGB(6, 5, 34)
    Friends.BackgroundColor3 = Color3.fromRGB(6, 5, 34)
    Games.BackgroundColor3 = Color3.fromRGB(6, 5, 34)
    Home.BackgroundColor3 = Color3.fromRGB(6, 5, 34)
    Settings.BackgroundColor3 = Color3.fromRGB(6, 5, 34)
    script.Parent.Parent.Parent.DarkMode.Value = true
  else
    script.Parent.Text = "Light Mode"
    wait (0.1)
    Create.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    Friends.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    Games.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    Home.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    Settings.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
    script.Parent.Parent.Parent.DarkMode.Value = false
  end
end)

After I capitalized it, it still has the same error, I’m not sure if it shows up in the script on the dev-forum website, the error is:
script.Parent.mouseButton1Click:Connect(function() script.Parent.Parent.Parent.Parent.DarkMode.Value == true else script.Parent.Parent.Parent.Parent.DarkMode.Value == false

Then is has the if script.Parent.Parent etc.

do you have an error in output?

Could you copy and paste the error message from the Output and send it here?

Output isn’t showing any errors at all, I’ll send a screenshot of the script and the heirarchy if that would help.
Screenshot:

Replace image with the following:

if script.Parent.Parent.Parent.Parent.DarkMode.Value == true then

elseif script.Parent.Parent.Parent.Parent.DarkMode.Value == false then

end

It worked perfectly, thank you!

or use this code:

if script.Parent.Parent.Parent.Parent.DarkMode.Value then
    print("Is Dark Mode!")
else
    print("Not Dark Mode!")
end

since it’s a bool value it will check the DarkMode value if it’s true without needing the “== true” part and else will mean it will be what happens if it’s false.

If you just want to check if it’s false without the else or == false then just do this:

if not script.Parent.Parent.Parent.Parent.DarkMode.Value then
    print("Not Dark Mode!")
end

I use that since it’s much easier and cleaner, but with what I know brings no performance impacts and is all down to preference to what you want to use to check BoolValues

1 Like

You could also just delete this line:

if script.Parent.Parent.Parent.Parent.DarkMode.Value == true then
end

And just use an if-else instead of a if-elseif because its either true or false and you don’t need to check the second statement. If the first is false, then the second will always be true.