Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

Why say thank you and not accept the answer? Accept it.

1 answer

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).

1 comment

0

OH I FORGOT ty sir

This discussion is preserved as it was. New answers, comments, and votes are closed.