I’m making a trading system and I found a tutorial that uses tools. But my games uses data in tables for each player and stuff, this is the module from the tutorial on how he accessed a players tools:
local config = {}
-------Settings you can change-------
config.MaxSlots = 9
config.TimeBeforeTradeConfirmed = 10
-------------------------------------
--Funcion for getting all the tools a player has
function config.GetTools(plr)
local plrTools = plr.Backpack:GetChildren()
local toolEquipped = plr.Character:FindFirstChildOfClass("Tool")
if toolEquipped then
table.insert(plrTools, toolEquipped)
end
return plrTools
end
return config
But my game uses data which is only in this server script I made:
local data = {}
--load player data
local function loadData(player)
local success = nil
local playerData = nil
local attempt = 1
repeat
success, playerData = pcall(function()
return dataBase:GetAsync(player.UserId)
end)
attempt += 1
if not success then
warn(playerData)
task.wait()
end
until success or attempt == 3
if success then
if not playerData then--give default data if they're new
playerData = {
["Gems"] = 0,
["SelectedTowers"] = {"Cameraguy"},
["OwnedTowers"] = {"Cameraguy"},
["MaxTowers"] = 5,
["RedeemedCodes"] = {}
}
beamEvent:FireClient(player)
end
data[player.UserId] = playerData
So my question is, how can I send this data to the module so the module script can access it and edit the module script return it. Any help is appreciated, thanks!