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

Why am I getting this error when loading a map? [Attempt to index field]

Asked by 5 years ago

Whenever I load the game, the map won't load because of this error? I have no idea why, Can someone help me?

Here is the script,

    local function set_lighting(mname)
        local dolist={"Ambient","ColorShift_Bottom","ColorShift_Top","OutdoorAmbient"}
        for i=1, #dolist do
            light[dolist[i]]=color(lightset[mname][dolist[i]][1]/255,lightset[mname][dolist[i]][2]/255,lightset[mname][dolist[i]][3]/255)
        end
        mapname.Value=lightset[mname].Name
    end

Here is the error that occurs when I load the game.

  20:53:34.461 - ServerScriptService.server:2152: attempt to index field '?' (a nil value)

Any help?

0
The 4th line is cut off a bit, It says this. light[dolist[i]]=color(lightset[mname][dolist[i]][1]/255,lightset[mname][dolist[i]][2]/255,lightset[mname][dolist[i]][3]/255). Yosufgamer -7 — 5y
0
this code looks oddly familiar... fusionFSJAL 33 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
local function set_lighting(mname)
    local dolist={"Ambient","ColorShift_Bottom","ColorShift_Top","OutdoorAmbient"}
    for i,v in pairs(dolist) do -- Switched to pairs to make it easier for you
        light[v]=Color3.new(lightset[mname][v][1]/255,lightset[mname][v][2]/255,lightset[mname][v][3]/255) -- You did not use "Color3.new" which is required for Color3 colors.
    end
    mapname.Value=lightset[mname].Name
end

If this helped, make sure to upvote/accept it!

0
color was probably defined to be Color3.new ihatecars100 502 — 5y
Ad

Answer this question