How can I make this disco mode script work?

Hello, I was making a disco mode script and the button clones a ColorCorrection into game.Lighting and enables the color correction when it is in the Lighting section. I added a script inside the ColorCorrection and that script doesn’t work.
Script:

if script.Parent.Enabled == true then
	print("Disco Mode is active.")
	while true do
		script.Parent.TintColor = Color3.fromRGB(255, 0, 4)
		wait(0.9)
		script.Parent.TintColor = Color3.fromRGB(19, 14, 181)
		wait(0.9)
		script.Parent.TintColor = Color3.fromRGB(170, 101, 255)
		wait(0.9)
		script.Parent.TintColor = Color3.fromRGB(148, 236, 255)
		wait(0.9)
	end
end
1 Like

Scripts don’t run in Lighting. Try putting the script in ServerScriptService.

Also, it would be best to connect your script to a PropertyChangedSignal function, so you can turn on/off disco mode.

local ColorCorrection = game.Lighting.ColorCorrection

ColorCorrection:GetPropertyChangedSignal("Enabled"):Connect(function() -- runs every time ColorCorrection is enabled/disabled
	print("Disco Mode is active.")
	while ColorCorrection.Enabled do -- stop loop when disabled
		ColorCorrection.TintColor = Color3.fromRGB(255, 0, 4)
		wait(0.9)
		ColorCorrection.TintColor = Color3.fromRGB(19, 14, 181)
		wait(0.9)
		ColorCorrection.TintColor = Color3.fromRGB(170, 101, 255)
		wait(0.9)
		ColorCorrection.TintColor = Color3.fromRGB(148, 236, 255)
		wait(0.9)
	end
end
1 Like