Help with Lighting property color changing

Hello! So I was creating a new game mode but apparently, the lighting property colors aren’t changing. Any help would be appreciated!

  1. This is a LocalScript inside of a ScreenGui inside of StarterGui.
  2. The value is inside of ReplicatedStorage.
    Here’s the script;
-- Variables --
local NightmareModeButton = script.Parent.NightmareModeButton
local NightmareModeValue = game.ReplicatedStorage:WaitForChild("NightmareModeValue")

local Lighting = game.Lighting
local Ambient = Lighting.Ambient
local OutdoorAmbient = Lighting.OutdoorAmbient
local FogColor = Lighting.FogColor
local FogEnd = Lighting.FogEnd
local FogStart = Lighting.FogStart

local debounce = false

-- Scripting --
NightmareModeButton.MouseButton1Click:Connect(function()
	if not debounce then
		debounce = true
		NightmareModeValue.Value = not NightmareModeValue.Value
		
		if NightmareModeValue.Value == true then
			Ambient = Color3.fromRGB(0, 0, 0)
			OutdoorAmbient = Color3.fromRGB(0, 0, 0)
			FogColor = Color3.fromRGB(0, 0, 0)
			FogEnd = 80
			FogStart = 10
		end
		
		wait(0.25)
		debounce = false
	end
end)

I might be gone for a bit. I’ll check the replies later on.

what is this?___________________________

the if only works if

if NightmareModeValue.Value == true then

It’s for making it turn on and off. The full script wasn’t finished that’s why it looks confusing. If I get a solution to changing the color then I’ll finish the full script. But even though the value was becoming on and off.

Edit: There wasn’t any errors in the output.

You should at least comment toggle the debounce so you can get the light working because the problem seems to be with the debounce.

1 Like

Hm, I’ll try using prints to see if something works or not.

So, I changed up some few stuff like removing the value and debounce, adding prints etc. But still nothing is working. Here’s the updated script;

-- Variables --
local NightmareModeButton = script.Parent.NightmareModeButton

local Lighting = game:GetService("Lighting")
local Ambient = Lighting.Ambient
local OutdoorAmbient = Lighting.OutdoorAmbient
local FogColor = Lighting.FogColor
local FogEnd = Lighting.FogEnd
local FogStart = Lighting.FogStart

-- Scripting --
NightmareModeButton.MouseButton1Click:Connect(function()
	Ambient = Color3.new(0, 0, 0)
	print("Ambient color changed to dark.")
	OutdoorAmbient = Color3.new(0, 0, 0)
	print("OutdoorAmbient color changed to dark.")
	FogColor = Color3.new(0, 0, 0)
	print("FogColor changed to dark.")
	FogEnd = 80
	print("FogEnd is now 80")
	FogStart = 10
	print("FogStart is now 10")
end)

When you’re referencing a property, you’re storing the current value into the variable, so what’s happening is that it’s only changing the variable. Your issue was not with the debounce, you need to reference the property to change it, not a variable.

Say you want to change the Ambient, referencing your Ambient variable just changes the variable, if you want change the property, reference the thing with that property and change it, in your case, Lighting.Ambient

You have to do that for the other 4 as well

1 Like

I’ll check if it works or not!

Thanks for helping! It worked!

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!

1 Like