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

Why are my lights not changing to the set color?

Whenever I use this script it changes the value of the lights color to some random number, not the numbers I have set, why is this?

for _, light in pairs(game.Workspace:GetDescendants()) do
	local surfaceLight = light:FindFirstChild("AdministrationLight")
	if surfaceLight then
		surfaceLight.Color = Color3.new(255, 255, 255)
	end
end

1 answer

✓ Accepted answer

You are using Color3.new() It is now required to use Color3.fromRGB() when doing RGB stuff.

Use this code:

for _, light in pairs(game.Workspace:GetDescendants()) do
	local surfaceLight = light:FindFirstChild("AdministrationLight")
	if surfaceLight then
		surfaceLight.Color = Color3.fromRGB(255, 255, 255)
	end
end

If you have any questions feel free to ask.

2 comments

1

Ah, I wasn't aware of that. Thank you, it works fine now.

0

It isn't required, it's just easier to use fromRGB. The Color3.new equivalent to Color3.fromRGB(255, 255, 255) is Color3.new(255/255, 255/255, 255/255), which is Color3.new(1, 1, 1). Color3.new()'s parameters only accept numerical arguments from 0 to 1.

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