Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a surface light in a part continuously change colour (RGB)?

How do I make that the Part named Light has a SurfaceLight that changes its colour (RGB) continuously?

2 answers

Just wrote a little script that changes a Light source change to all the colours of the spectrum it also has a way to change the whiteness and the darkness (commented out) it also uses the part where the light source is in and colours it accordingly to make it look like its emitting light

Code:

local Light = script.Parent.SurfaceLight
local LightBrick = script.Parent

-- these are the colour values all range from 0 to 1, they start from these
local C = 0 -- colour value
local S = 1 -- How white the colour is 
local V = 1 -- how dark the colour is 


-- how much to change the colour values by
local C_Step = 0.001
local S_Step = 0.001
local V_Step = 0.01
local S_Tog = false
local V_Tog = false

-- comment this out if not needed!
LightBrick .Material = Enum.Material.Neon


-- main loop
while true do
	Light.Color = Color3.fromHSV(C,S,V)
	LightBrick.Color = Color3.fromHSV(C,S,V)
	wait()
	--[[ un comment this to change the Whiteness and darkness of your colours, it flip flops between 0 and 1
	if(S_Tog == false) then
		if(S < 1) then 
			S = S + S_Step 
		else 
			S_Tog = true 	
		end
	else 
		if(S > 0) then 
			S = S + S_Step 
		else 
			S_Tog = false 
		end 
	end
	if(V_Tog == false) then	
		if(V < 1) then 
			V = V + V_Step 
		else 
			V_Tog = true 
		end
	else 
		if(V > 0) then 
			V = V + V_Step 
		else 
			V_Tog = false 
		end 
	end
	]]
	-- main bit that cycles the colours
	C = C +C_Step <=1 and C+C_Step or 0
end

Make a SurfaceLight in a part and if you want make the part transparent Put a script in the SurfaceLight and this is the script

while true do script.Parent.Color = Color3.new(math.random(), math.random(), math.random()) wait(0.5) end

This discussion is preserved as it was. New answers, comments, and votes are closed.