Not finding the GUI not on just one but mulple scipts

My GUI is not vaild for some reason.

The other script is

local ui = script.Parent.Parent.Parent.Parent.TasksGUI
local boolValue = ui.Music.Value-- Change it to wherever you put it and what you named it
local music = game.ReplicatedStorage.CurrentMusic

script.Parent.MouseButton1Click:Connect(function()
	if boolValue == true then
		boolValue = false
	else 
		boolValue = true
	end
end)
while true do
	wait()
	if boolValue == false then
		script.Parent.Text = "TURN ON"
		music.Volume = 0

	else
		script.Parent.Text = "TURN OFF"
		music.Volume = 0.5
	end
end

A good solution would be adding a DarkMode BoolValue in the player object(not the leaderstats folder) and reading it from there by doing player.DarkMode.Value.

2 Likes

Could you possibly show your code from your script that handles the DarkMode?

Its not real anything.

Its basically this

if scipt.Parent.Text == "TURN ON" then
--- Make all UI dark

elseif script.Parent.Text == "Turn OFF" then
--- Make UI orginal color again

I just grab every UI object and make it to that color.

1 Like

How would I make a bool value?

If anyone could answer that would be nice.

Click the add button and type in “Bool Value” and insert it into a folder or whatever you prefer to place it in, then add in the script the local variable of what you named the bool value:

Note: Put the value under the script. That’s what I recommend doing.

local boolValue = game.Workspace.BoolValue.Value -- Change it to wherever you put it and what you named it
boolValue = false

if boolValue == false then
   boolValue = true 
   script.Parent.Text == "TURN OFF"
   print("Dark Mode Activated!")
else
   boolValue = false
   script.Parent.Text == "TURN ON"
end

Try that and see if it works.

1 Like

Ok theres a new problem now.

So it wont find this GUI for some reason (On Line 84). I put a 84 by it.

local boolValue = script.Parent.Parent.Parent.Parent.TasksGUI.DarkMode.Value -- Change it to wherever you put it and what you named it
local Gray = Color3.new(0.309804, 0.309804, 0.309804)
local Gray2 = Color3.new(0.478431, 0.478431, 0.478431)
local Blue = Color3.new(0, 0.666667, 1)
local Blue2 = Color3.new(0, 0.564706, 0.847059)
local UI = script.Parent.Parent.Parent


script.Parent.MouseButton1Click:Connect(function()
	if boolValue == true then
		boolValue = false
	else
		boolValue = true
	end
end)
while true do
	wait()
	if boolValue == true then
		script.Parent.Text = "TURN OFF"
		---
		script.Parent.BackgroundColor3 = Gray2
		script.Parent.Parent.MusicOnOff.BackgroundColor3 = Gray2
		script.Parent.Parent.BackgroundColor3 = Gray
		UI.CodesFrame.EnterButton.BackgroundColor3 = Gray2
		UI.CodesFrame.Title.BackgroundColor3 = Gray2
		UI.CodesFrame.BackgroundColor3 = Gray
		UI.Coins.BackgroundColor3 = Gray
		UI.FeedbackFrame.BackgroundColor3 = Gray
		UI.Hearts.BackgroundColor3 = Gray
		UI.MainMenuBar.BackgroundColor3 = Gray
		UI.MenuFrame.BackgroundColor3 = Gray
		UI.MenuFrame.CalmRoom.BackgroundColor3 = Gray2
		UI.MenuFrame.Codes.BackgroundColor3 = Gray2
		UI.MenuFrame.Feedback.BackgroundColor3 = Gray2
		UI.MenuFrame.Settings.BackgroundColor3 = Gray2
		UI.ShopandHintBar.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.Boosts.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.Coins.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.Donate.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.Gampass.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.x2HealthFrame.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.x2CoinsFrame.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.x2WinsFrame.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.x2HealthFrame.BuyBtn.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.x2CoinsFrame.BuyBtn.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.x2WinsFrame.BuyBtn.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.CoinsFrame.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.CoinsFrame.Coins100.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.CoinsFrame.Coins1000.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.CoinsFrame.Coins500.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.CoinsFrame.Coins250.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.DonateFrame.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.DonateFrame.Donate10.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.DonateFrame.Donate100.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.DonateFrame.Donate20.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.DonateFrame.Donate5.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.DonateFrame.Donate50.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.DonateFrame.Donate500.BackgroundColor3 = Gray2
		UI.Wins.BackgroundColor3 = Gray
		script.Parent.Parent.Parent.Parent.TasksGUI.Tasks.BackgroundColor3 = Gray
		script.Parent.Parent.Parent.Parent.MusicNotifierGUI.Notifier.BackgroundColor3 = Gray

	else
		script.Parent.Text = "TURN ON"
		---
		script.Parent.BackgroundColor3 = Blue2
		script.Parent.Parent.MusicOnOff.BackgroundColor3 = Blue2
		script.Parent.Parent.BackgroundColor3 = Blue
		UI.CodesFrame.EnterButton.BackgroundColor3 = Blue2
		UI.CodesFrame.Title.BackgroundColor3 = Blue2
		UI.CodesFrame.BackgroundColor3 = Blue
		UI.Coins.BackgroundColor3 = Blue
		UI.FeedbackFrame.BackgroundColor3 = Blue
		UI.Hearts.BackgroundColor3 = Blue
		UI.MainMenuBar.BackgroundColor3 = Blue
		UI.MenuFrame.BackgroundColor3 = Blue
		UI.MenuFrame.CalmRoom.BackgroundColor3 = Blue2
		UI.MenuFrame.Codes.BackgroundColor3 = Blue2
		UI.MenuFrame.Feedback.BackgroundColor3 = Blue2
		UI.MenuFrame.Settings.BackgroundColor3 = Blue2
		UI.ShopandHintBar.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.Boosts.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.Coins.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.Donate.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.Gampass.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.x2HealthFrame.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.x2CoinsFrame.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.x2WinsFrame.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.x2HealthFrame.BuyBtn.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.x2CoinsFrame.BuyBtn.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.x2WinsFrame.BuyBtn.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.CoinsFrame.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.CoinsFrame.Coins100.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.CoinsFrame.Coins1000.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.CoinsFrame.Coins500.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.CoinsFrame.Coins250.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.DonateFrame.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.DonateFrame.Donate10.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.DonateFrame.Donate100.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.DonateFrame.Donate20.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.DonateFrame.Donate5.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.DonateFrame.Donate50.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.DonateFrame.Donate500.BackgroundColor3 = Blue2
		UI.Wins.BackgroundColor3 = Blue
--84    script.Parent.Parent.Parent.Parent.TasksGUI.Tasks.BackgroundColor3 = Blue
		script.Parent.Parent.Parent.Parent.MusicNotifierGUI.Notifier.BackgroundColor3 = Blue
	end
end

Why’re you using script.Parent.Parent and so on?, couldn’t you just use LocalPlayer? and the player might’ve not been loaded so the use of WaitForChild would might make a difference.

1 Like

Another thing, the UI.SomeThing.BackgroundColor3 = Blue2 is really inefficient, instead. You could try looping through all the objects in your UI and setting the BackgroundColor3 from there such as:


for i,v in pairs(UI:GetDescendants()) do
    v.BackgroundColor3 = -- your colour 
end
1 Like

Not all UI need to be changed.

Scipt.Parent is easier…

DO you have any solution to the problem???

I said use WaitForChild, game.Players.LocalPlayer is easier in my opinion but okay.

1 Like

That did not work.

WaitForChild did not work.

Why game .Players.LocalPlayer???

Thats just a extra step…

I will try it though maybe it works.

1 Like

Please use for loops to go through out scriot.Parent and UI your code is not optimized

What do you mean??

@ThoseNamesAreGood It didnt work

Could it be because I don’t have a property enabled on the GUI??

What do you mean property enabled?, could you please show us your current script?

1 Like

Its basically the same.

local boolValue = game.Players.LocalPlayer.PlayerGui.TasksGUI.DarkMode.Value-- Change it to wherever you put it and what you named it
local Gray = Color3.new(0.309804, 0.309804, 0.309804)
local Gray2 = Color3.new(0.478431, 0.478431, 0.478431)
local Blue = Color3.new(0, 0.666667, 1)
local Blue2 = Color3.new(0, 0.564706, 0.847059)
local UI = script.Parent.Parent.Parent
local UI2 = game.Players.LocalPlayer.PlayerGui.TasksGUI
local UI3 = game.Players.LocalPlayer.PlayerGui.MusicNotifierGUI


script.Parent.MouseButton1Click:Connect(function()
	if boolValue == true then
		boolValue = false
	else
		boolValue = true
	end
end)
while true do
	wait()
	if boolValue == true then
		script.Parent.Text = "TURN OFF"
		---
		script.Parent.BackgroundColor3 = Gray2
		script.Parent.Parent.MusicOnOff.BackgroundColor3 = Gray2
		script.Parent.Parent.BackgroundColor3 = Gray
		UI.CodesFrame.EnterButton.BackgroundColor3 = Gray2
		UI.CodesFrame.Title.BackgroundColor3 = Gray2
		UI.CodesFrame.BackgroundColor3 = Gray
		UI.Coins.BackgroundColor3 = Gray
		UI.FeedbackFrame.BackgroundColor3 = Gray
		UI.Hearts.BackgroundColor3 = Gray
		UI.MainMenuBar.BackgroundColor3 = Gray
		UI.MenuFrame.BackgroundColor3 = Gray
		UI.MenuFrame.CalmRoom.BackgroundColor3 = Gray2
		UI.MenuFrame.Codes.BackgroundColor3 = Gray2
		UI.MenuFrame.Feedback.BackgroundColor3 = Gray2
		UI.MenuFrame.Settings.BackgroundColor3 = Gray2
		UI.ShopandHintBar.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.Boosts.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.Coins.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.Donate.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.Gampass.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.x2HealthFrame.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.x2CoinsFrame.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.x2WinsFrame.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.x2HealthFrame.BuyBtn.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.x2CoinsFrame.BuyBtn.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.x2WinsFrame.BuyBtn.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.CoinsFrame.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.CoinsFrame.Coins100.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.CoinsFrame.Coins1000.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.CoinsFrame.Coins500.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.CoinsFrame.Coins250.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.DonateFrame.BackgroundColor3 = Gray
		UI.ShopnGampassFrame.DonateFrame.Donate10.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.DonateFrame.Donate100.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.DonateFrame.Donate20.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.DonateFrame.Donate5.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.DonateFrame.Donate50.BackgroundColor3 = Gray2
		UI.ShopnGampassFrame.DonateFrame.Donate500.BackgroundColor3 = Gray2
		UI.Wins.BackgroundColor3 = Gray
		UI2.Tasks.BackgroundColor3 = Gray
		UI3.Notifier.BackgroundColor3 = Gray

	else
		script.Parent.Text = "TURN ON"
		---
		script.Parent.BackgroundColor3 = Blue2
		script.Parent.Parent.MusicOnOff.BackgroundColor3 = Blue2
		script.Parent.Parent.BackgroundColor3 = Blue
		UI.CodesFrame.EnterButton.BackgroundColor3 = Blue2
		UI.CodesFrame.Title.BackgroundColor3 = Blue2
		UI.CodesFrame.BackgroundColor3 = Blue
		UI.Coins.BackgroundColor3 = Blue
		UI.FeedbackFrame.BackgroundColor3 = Blue
		UI.Hearts.BackgroundColor3 = Blue
		UI.MainMenuBar.BackgroundColor3 = Blue
		UI.MenuFrame.BackgroundColor3 = Blue
		UI.MenuFrame.CalmRoom.BackgroundColor3 = Blue2
		UI.MenuFrame.Codes.BackgroundColor3 = Blue2
		UI.MenuFrame.Feedback.BackgroundColor3 = Blue2
		UI.MenuFrame.Settings.BackgroundColor3 = Blue2
		UI.ShopandHintBar.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.Boosts.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.Coins.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.Donate.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.Gampass.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.x2HealthFrame.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.x2CoinsFrame.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.x2WinsFrame.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.x2HealthFrame.BuyBtn.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.x2CoinsFrame.BuyBtn.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.x2WinsFrame.BuyBtn.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.CoinsFrame.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.CoinsFrame.Coins100.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.CoinsFrame.Coins1000.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.CoinsFrame.Coins500.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.CoinsFrame.Coins250.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.DonateFrame.BackgroundColor3 = Blue
		UI.ShopnGampassFrame.DonateFrame.Donate10.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.DonateFrame.Donate100.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.DonateFrame.Donate20.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.DonateFrame.Donate5.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.DonateFrame.Donate50.BackgroundColor3 = Blue2
		UI.ShopnGampassFrame.DonateFrame.Donate500.BackgroundColor3 = Blue2
		UI.Wins.BackgroundColor3 = Blue
		UI2.Tasks.BackgroundColor3 = Blue
		UI3.Notifier.BackgroundColor3 = Blue
	end
end

I mean in here.

But why cant it find that UI??