Why is this nil?

Any idea why Mode is nil? I tried printing CurrentCharInfo and CurrentCharInfo[“Modes”] and neither were nil but Mode just is. Why?
Thanks!

--Get info about current character
local CurrentCharInfo = RequestCharInfo:InvokeServer("current")

local ModeIndex = 0
local Mode = nil
local ModName = script.Parent.coloredModName

--Listen for input of the E or Q key
UserInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.E then
        ModeIndex = ModeIndex + 1
        Mode = CurrentCharInfo["Modes"][ModeIndex]
        print(Mode) -- nil
        ModName.Text = Mode.Name
        local BrickColoredColor = BrickColor.new(Mode.Color)
        ModName.TextColor3 = Color3.new(BrickColoredColor.r, BrickColoredColor.g, BrickColoredColor.b)
    end
end)

Maybe the value of “ModeIndex” does not exist in “Modes”

Right here: CurrentCharInfo[“Modes”][ModeIndex]

1 Like