Why is this var nil?

Hi, I have this code:

    local IdealIcon = Player:WaitForChild("LeaderboardIcon")
local IdealIconValue = IdealIcon.Value

    playerDataCache[Player.UserId] = {

        isRedacted = "",

        Icon = ""

    }

    playerDataCache[Player.UserId].isRedacted = IsRedacted.Value

    if IdealIconValue ~= "None" then

        print(IdealIconValue)

        local IconID = IconsModule.IdealIconValue

        print(IconID)

So, at the end of the code, you can see I tried printing IdealIconValue, it prints Owner, but when I print IconID, it’s nil, here is IconsModule. Any ideas?

return {

["Owner"] = 7529276835,

["Developer"] = 7529273928,

["Overseer"] = 7529268207,

["InternalSecurity"] = 6523858394,

["Upholder"] = 7529261195,

["Judicial"] = 4759519079,

["RobloxAdmin"] = 7529253809,

["VideoStar"] = 7529249715,

["Premium"] = 6071020687

}

You need to get it like that IconsModule[IdealIconValue] because with . operator the script assumes that there’s index ["IdealIconValue"] = 00000 in the IconsModule.

1 Like