How do i get a table name in a module script

this is the code i wrote Holder.CharInfo.CharName.Text = CharStats[tostring("Kirby")] but it says unable to assign property text string expected got nil

im very new to module scripts

:wilted_flower: can you at least tell me what im doing wrong

CharStats[tostring(“Kirby”)] doesnt exist

the table is in the module script

image

You’re going to have to share more than that :woozy_face: That literally tells nobody anything.

its a module, with a table…

???

local module = {}
local Kirby = {
}
return module

You have defined kirby as a local variable in the module. Unless a reference to it is returned by the modulescript you won’t be able to access it.

You need to do:

local module = {}
module.Kirby = {}

return module

If that’s all then no wonder. You have to return the table.

local CharStats = {
    Kirby = {
        Name = "Kirby",
        -- data
    }
    -- data
}

return CharStats
local CharStats = require(<path>)

...

Holder.CharInfo.CharName.Text = CharStats.Kirby.Name

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