Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why are my lights not changing to the set color?

Asked by 4 years ago
Edited by Azarth 4 years ago

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

Log in to vote
1
Answered by
Torren_Mr 334 Moderation Voter
4 years ago
Edited by Azarth 4 years ago

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.

1
Ah, I wasn't aware of that. Thank you, it works fine now. ConnorThomp 87 — 4y
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. DeceptiveCaster 3761 — 4y
Ad

Answer this question