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

How can I fix this error: Attempt to call upvalue 'Xp_LvlModule' (a table value)?[SOLVED]

Asked by 5 years ago
Edited 5 years ago

If you can please explain the "(a table value)" part for me pleas

-- Variables
local xp_lvl_DataStore = game:GetService('DataStoreService'):GetDataStore('xp/lvlStore')
local repStorage = game:GetService('ReplicatedStorage')
local serverScriptStore = game:GetService('ServerScriptService')
local xpChanger = repStorage:WaitForChild('Xp_LvlChanged')
local xpToAdd = 5
local part = script.Parent
local maxLvl = 350
local xp_LvlModule = require (serverScriptStore.Xp_LvlModule)

-- Events
local success,message = pcall (part.ClickDetector.MouseClick:Connect(function(plr)
    local key = 'Player-'..plr.UserId
    local xpLvlTable = xp_lvl_DataStore:GetAsync(key)
    -- Fire to player
    xpChanger:FireClient(plr,xpToAdd)
    -- Sends added xp then saves
    xp_LvlModule(xpToAdd,key)
    print('Xp: '..xpLvlTable[1]..' Lvl: '..xpLvlTable[2])
end))

It errors on line 18

0
Why say thank you and not accept the answer? Accept it. User#19524 175 — 5y

1 answer

Log in to vote
0
Answered by
thebayou 441 Moderation Voter
5 years ago
Edited 5 years ago

xp_LvlModule is the module script that you required on line 09, and module scripts aren't callable. You're trying to call a function inside the module script, so you have to index it by specifying the function name as well: xp_LvlModule.FunctionName(params).

0
OH I FORGOT ty sir RichCookieGamer 7 — 5y
Ad

Answer this question