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

I make a lamp that changes a color every 0.5 sec, but code does not work,can you help me?

here code:

local light = script.Parent	

while true do

	local r = math.random(1,254)
	wait(0.0001)
	local g = math.random(1,254)
	wait(0.0001)
	local b = math.random(1,254)
	wait(0.0001)

	local rColor = Color3.new(r,g,b)
	light.Color += rColor

	wait(0.5)
end

error:

Workspace.Model.Part.PointLight.Script:15: attempt to perform arithmetic (add) on Color3

1 comment

0

i have already made)

1 answer

i have already made)

answer:

local light = script.Parent

while true do

	local r = math.random(1, 254)
	wait(0.0001)
	local g = math.random(1 ,254)
	wait(0.0001)
	local b = math.random(1, 254)
	wait(0.0001)

	local rColor = Color3.fromRGB(r, g, b)

	light.Color = rColor

	print(rColor)
	print(light.Color)
	wait(5)
end

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