Need help with night and day change button

Forgot to add .TextColor3 to the end. That should work now!

if game.Players.LocalPlayer:FindFirstChild("Value") == nil then
	
	Instance.new("BoolValue").Parent = game.Players.LocalPlayer
	game.Players.LocalPlayer.Value.Name = "DayNightValue"
end

local Image = script.Parent.Parent.Image
local Day = "rbxassetid://7546458145"
local Night = "rbxassetid://7546428910"
local DayColor = Color3.new(1,1,1)
local NightColor = Color3.new(0,0,0)
local BoolValue = game.Players.LocalPlayer.DayNightValue
local Lighting = game.Lighting
local StartGui = game.Players.LocalPlayer.PlayerGui.StartGui
local ScoreGui = game.Players.LocalPlayer.PlayerGui.ScoreGui


if BoolValue.Value == false then
	Image.Image = Day
	ScoreGui.PlayButton.TextColor3 = DayColor
	ScoreGui.TextLabel.TextColor3 = DayColor
	ScoreGui.BestScoreButton.TextColor3 = DayColor
	StartGui.ScoreButton.TextColor3 = DayColor
else	
	Image.Image = Night
	ScoreGui.PlayButton.TextColor3 = NightColor
	ScoreGui.TextLabel.TextColor3 = NightColor
	ScoreGui.BestScoreButton.TextColor3 = NightColor
	StartGui.ScoreButton.TextColor3 = NightColor
end

script.Parent.MouseButton1Click:Connect(function()
	if BoolValue.Value == false then
		Lighting.TimeOfDay = "00:00:00"
		Image.Image = Night 
		ScoreGui.PlayButton.TextColor3 = NightColor
		ScoreGui.TextLabel.TextColor3 = NightColor
		ScoreGui.BestScoreButton.TextColor3 = NightColor
		StartGui.ScoreButton.TextColor3 = NightColor
		BoolValue.Value = true
	else
		Lighting.TimeOfDay = "14:00:00"
		Image.Image = Day
		ScoreGui.PlayButton.TextColor3 = DayColor
		ScoreGui.TextLabel.TextColor3 = DayColor
		ScoreGui.BestScoreButton.TextColor3 = DayColor
		StartGui.ScoreButton.TextColor3 = DayColor
			BoolValue.Value = false
	end
	end)
1 Like

if the player die the text back to black

Sorry bro i will try to do it myself because its hard to you to do it because you did not make the game ty for your help

I know why, the colours are just the wrong way round. Should it be white at night and black at day?

1 Like

yes black in day and white in night

Try this, the colours were the wrong way round.


if game.Players.LocalPlayer:FindFirstChild("Value") == nil then
	
	Instance.new("BoolValue").Parent = game.Players.LocalPlayer
	game.Players.LocalPlayer.Value.Name = "DayNightValue"
end

local Image = script.Parent.Parent.Image
local Day = "rbxassetid://7546458145"
local Night = "rbxassetid://7546428910"
local DayColor = Color3.new(0,0,0)
local NightColor = Color3.new(1,1,1)
local BoolValue = game.Players.LocalPlayer.DayNightValue
local Lighting = game.Lighting
local StartGui = game.Players.LocalPlayer.PlayerGui.StartGui
local ScoreGui = game.Players.LocalPlayer.PlayerGui.ScoreGui


if BoolValue.Value == false then
	Image.Image = Day
	ScoreGui.PlayButton.TextColor3 = DayColor
	ScoreGui.TextLabel.TextColor3 = DayColor
	ScoreGui.BestScoreButton.TextColor3 = DayColor
	StartGui.ScoreButton.TextColor3 = DayColor
else	
	Image.Image = Night
	ScoreGui.PlayButton.TextColor3 = NightColor
	ScoreGui.TextLabel.TextColor3 = NightColor
	ScoreGui.BestScoreButton.TextColor3 = NightColor
	StartGui.ScoreButton.TextColor3 = NightColor
end

script.Parent.MouseButton1Click:Connect(function()
	if BoolValue.Value == false then
		Lighting.TimeOfDay = "00:00:00"
		Image.Image = Night 
		ScoreGui.PlayButton.TextColor3 = NightColor
		ScoreGui.TextLabel.TextColor3 = NightColor
		ScoreGui.BestScoreButton.TextColor3 = NightColor
		StartGui.ScoreButton.TextColor3 = NightColor
		BoolValue.Value = true
	else
		Lighting.TimeOfDay = "14:00:00"
		Image.Image = Day
		ScoreGui.PlayButton.TextColor3 = DayColor
		ScoreGui.TextLabel.TextColor3 = DayColor
		ScoreGui.BestScoreButton.TextColor3 = DayColor
		StartGui.ScoreButton.TextColor3 = DayColor
			BoolValue.Value = false
	end
	end)

i tried to change it but the same thing happen

i must to go now ty i will try to make it myself

1 Like

This has been updated quickly and tested. It 100% works.

if game.Players.LocalPlayer:FindFirstChild("Value") == nil then
	
	Instance.new("BoolValue").Parent = game.Players.LocalPlayer
	game.Players.LocalPlayer.Value.Name = "DayNightValue"
end

local Image = script.Parent
local Day = "rbxassetid://7546458145"
local Night = "rbxassetid://7546428910"
local DayColor = Color3.new(0,0,0)
local NightColor = Color3.new(1,1,1)
local BoolValue = game.Players.LocalPlayer.DayNightValue
local Lighting = game.Lighting
local StartGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("StartGui")
local ScoreGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScoreGui")


if BoolValue.Value == false then
	Image.Image = Day
	StartGui.PlayButton.TextColor3 = DayColor
	StartGui.TextLabel.TextColor3 = DayColor
	StartGui.BestScoreButton.TextColor3 = DayColor
	ScoreGui.ScoreButton.TextColor3 = DayColor
else	
	Image.Image = Night
	StartGui.PlayButton.TextColor3 = NightColor
	StartGui.TextLabel.TextColor3 = NightColor
	StartGui.BestScoreButton.TextColor3 = NightColor
	ScoreGui.ScoreButton.TextColor3 = NightColor
end

script.Parent.MouseButton1Click:Connect(function()
	if BoolValue.Value == false then
		Lighting.TimeOfDay = "00:00:00"
		Image.Image = Night 
		StartGui.PlayButton.TextColor3 = NightColor
		StartGui.TextLabel.TextColor3 = NightColor
		StartGui.BestScoreButton.TextColor3 = NightColor
		ScoreGui.ScoreButton.TextColor3 = NightColor
		BoolValue.Value = true
	else
		Lighting.TimeOfDay = "14:00:00"
		Image.Image = Day
		StartGui.PlayButton.TextColor3 = DayColor
		StartGui.TextLabel.TextColor3 = DayColor
		StartGui.BestScoreButton.TextColor3 = DayColor
		ScoreGui.ScoreButton.TextColor3 = DayColor
			BoolValue.Value = false
	end
	end)
1 Like

DayNightCycleDevforum.rbxl (27.7 KB)

1 Like

tyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy. aaaa

tysm bro thats work tysmmmmmmmm

1 Like