Unable to cast value to object error

You can write your topic however you want, but you need to answer these questions:

  1. Once trying to adjust lighting module to handle atmospheric fog started receiving this error. (Sorry line # wont be accurate in error as I’m using an obfuscated version

local da = {
    _LoadPriority = 4,
    _Loaded = false,
    _Identity = 'circadian'
}
local _b = game:GetService('TweenService')
local ab = game:GetService('Lighting')
local bb =
ab:FindFirstChild('CircadianCorrection') or Instance.new('ColorCorrectionEffect', ab)
local cb = 1 / 85
local db = ab:FindFirstChild('Atmosphere')
local function db(bc)
    local cc = {}
    for dc, _d in pairs(bc) do
        local ad = TweenInfo.new(_d._EndTime - dc * cb, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
        cc[dc] = {
            _b:Create(ab, ad, _d.Lighting),
            _b:Create(bb, ad, _d.ColorCorrection),
            _b:Create(db, ad, _d.Atmosphere)
        }
    end;
    return cc
end;
local _c = nil

My version of line 9 is

cc[dc]={_b:Create(ab,ad,_d.Lighting),_b:Create(bb,ad,_d.ColorCorrection),_b:Create(db,ad,_d.Atmosphere)}end;return cc end;local _c=nil```

Please do not obfuscate your server scripts, it serves absolutely no purpose, these scripts are never shared with the client anyway. All you are doing is making the script harder to debug.

The problem looks like you’re giving the Create method separate values to change, when the method accepts a dictionary with key-value pairs of the property name and the value to tween the property to.

However I’m not sure what the content of bc or _d is, sharing that would be helpful.

1 Like

I’m editing old code for a group the previous scripter obfuscated it - bc is a value in a loop as is _d

for dc,_d in pairs(bc)do

local function db(bc)local cc={}

for dc,_d in pairs(bc)do

just values used to cycle through the loop

I meant sharing what the two contain, what are the values in bc, what are the keys and values in _d? The problem likely arises from _d.Lighting, and the other values being values of their corresponding properties and not dictionaries with the format I mentioned before. E.g.

local goal = {
    Transparency = 1,
    BrickColor = BrickColor.new("Really red")
    -- Goals defined by property-goal pairs
}

Can’t figure it out and I don’t know how much this helps but I found the table it references I think

local cc={[4.5]={_EndTime=6.5,Lighting={Ambient=Color3.fromRGB(30,30,30),OutdoorAmbient=Color3.fromRGB(59,63,93)},Atmosphere={Density=0.395,Offset=0,Color=Color3.fromRGB(199,170,107),Decay=Color3.fromRGB(92,60,13),Glare=0,Haze=0},ColorCorrection={Brightness=
-0.06,Contrast=0,Saturation=-0.04,TintColor=Color3.fromRGB(213,213,245)}},[6.5]={_EndTime=7.5,Lighting={Ambient=Color3.fromRGB(47,47,47),OutdoorAmbient=Color3.fromRGB(102,84,113)},Atmosphere={Density=0.395,Offset=0,Color=Color3.fromRGB(199,170,107),Decay=Color3.fromRGB(92,60,13),Glare=0,Haze=0},ColorCorrection={Brightness=
-0.1,Contrast=0.01,Saturation=-0.02,TintColor=Color3.fromRGB(255,213,255)}},[7.5]={_EndTime=8.5,_Time=1,Lighting={Ambient=Color3.fromRGB(84,84,84),OutdoorAmbient=Color3.fromRGB(120,120,120)},Atmosphere={Density=0.395,Offset=0,Color=Color3.fromRGB(199,170,107),Decay=Color3.fromRGB(92,60,13),Glare=0,Haze=0},ColorCorrection={Brightness=
-0.06,Contrast=0.01,Saturation=0.02,TintColor=Color3.fromRGB(255,255,255)}},[17.5]={_EndTime=18.5,Lighting={Ambient=Color3.fromRGB(47,47,47),OutdoorAmbient=Color3.fromRGB(113,101,97)},Atmosphere={Density=0.395,Offset=0,Color=Color3.fromRGB(199,170,107),Decay=Color3.fromRGB(92,60,13),Glare=0,Haze=0},ColorCorrection={Brightness=
-0.06,Contrast=0.04,Saturation=0.09,TintColor=Color3.fromRGB(255,218,187)}},[18.5]={_EndTime=19.5,Lighting={Ambient=Color3.fromRGB(30,30,30),OutdoorAmbient=Color3.fromRGB(65,65,65)},Atmosphere={Density=0.395,Offset=0,Color=Color3.fromRGB(199,170,107),Decay=Color3.fromRGB(92,60,13),Glare=0,Haze=0},ColorCorrection={Brightness=
-0.07,Contrast=0,Saturation=-0.18,TintColor=Color3.fromRGB(140,156,173)}}}