Why doesn't this work

Im basically trying to make a night vision script that sets the lighting to something and it works. but im trying to make a script in which if i click again that turns off, i tried to make that but the script here doesn’t work. Why?

local lighting = game:GetService("Lighting")
local key = game:GetService("UserInputService")

key.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.N then
		lighting.Brightness = 5
		lighting.ColorCorrection.Contrast = 1
	else
		lighting.Brightness = 0
		lighting.ColorCorrection.Contrast = 0
	end
end)

try this:

local lighting = game:GetService("Lighting")
local key = game:GetService("UserInputService")

key.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.N then
		local b, c = 5, 1

		if lighting.Brightness >= 4.9 and lighting.ColorCorrection.Contrast >= 0.9 then
			b = 0
			c = 0
		end

		lighting.Brightness = b
		lighting.ColorCorrection.Contrast = c

	end
end)

Doesn’t seem to change the lighting back to normal after clicking “N” again.

add a print there to see if it goes there:

if lighting.Brightness >= 4.9 and lighting.ColorCorrection.Contrast >= 0.9 then
     print("Goes there")
			b = 0
			c = 0
		end

It doesn’t print the “Goes There”

let’s try something else:

local lighting = game:GetService("Lighting")
local key = game:GetService("UserInputService")

key.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.N then
		local b, c = 5, 1

		if lighting.Brightness > 0 then
			print("Bright")
			b = 0
			
		end

		if lighting.ColorCorrection.Contrast >= 0 then
			print("Contrast")
			c = 0
			
		end

		lighting.Brightness = b
		lighting.ColorCorrection.Contrast = c

	end
end)

It kind of works but the lightings different, but thats my problem though. THanks for helping

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.