Help with Module Script and Color3s

I’m currently working on a module script that connects to a regular script to change the color of lights. The first light change works, but the second after task.wait(4) doesnt. How can I fix this?

Module:

local TweenService = game:GetService("TweenService")

local Helper = {}

function Helper.adjustLights(descendantsTable, objType : string, tweenInfo : TweenInfo, brightnessValue : number)
    for i,v in pairs(descendantsTable) do
        if v:IsA(objType) then
            TweenService:Create(v, tweenInfo, {Brightness = brightnessValue}):Play()
        end
    end
end

-- SCRIPT USED FOR COLOR:
function Helper.adjustcolor(descendantsTable, objType: string, tweenInfo : TweenInfo, colorValue)
    for i,v in pairs(descendantsTable) do
        if v:IsA(objType) then
            TweenService:Create(v, tweenInfo, {Color = Color3.fromRGB(colorValue)}):Play()
        end
    end
end
return Helper

Script:

local servScriptServ = game.ServerScriptService
local helper = require(servScriptServ.Helper)

task.wait(4)
helper.adjustcolor(workspace.Light:GetDescendants(), "SpotLight", TweenInfo.new(3, Enum.EasingStyle.Sine), 255, 0, 0)
task.wait(4)
helper.adjustcolor(workspace.Light:GetDescendants(), "SpotLight", TweenInfo.new(3, Enum.EasingStyle.Sine), 136, 255, 0)
print("Color Changed")

“Color Changed” still prints so I’m unsure what my error is. The color simply just fades instead of changing.

1 Like

That’s because you are only using one of the color values, not all of them. Try this instead:

function Helper.adjustcolor(descendantsTable, objType: string, tweenInfo : TweenInfo, colorRedValue, colorGreenValue, colorBlueValue)
    -- change color like this in tween
    {Color = Color3.fromRGB(colorRedValue, colorGreenValue, colorBlueValue)
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.