Hi! I have recently started using ProfileService as it’s better for bigger scaled projects and I wanted to try it out. I am currently trying to save a table in the ProfileService but when I try to add anything to the table an error will occur saying that the table provided is an int value. I have a table in the Template called “Bats”, this is the item I want to store for a player.
local Template = {
Gold = 250,
Emeralds = 0,
Kills = 0,
Level = 1,
XP = 100,
MaxXP = 100,
Bats = {},
}
Now when I try to add anything to that function with the Get() function:
function module:Get(plr)
local profile = Profiles[plr]
if profile then
return profile.Data
end
end
After this I used the Get() function:
function module.CheckBatInfoForPurchase(plr, Toolname, price, spd, dmg)
print(Toolname, price, spd, dmg)
local data = module:Get(plr)
if plr then
for i, v in pairs(module.BatInfo) do
if v.batName == Toolname then
print("List Checked!")
Toolname = v.batName
price = v.Price
spd = v.attackRate
dmg = v.Damage
print(price)
if plr.leaderstats.Gold.Value >= price then
print("Bought")
local bat = getBat(Toolname)
plr.leaderstats.Gold.Value -= price
table.insert(data.Bats, Toolname)
print(data.Bats)
end
end
end
end
end
This function will check if someone tries to buy a bat and then adds it to the data.Bats table in the template… but I get this error when trying to insert a value into the table:
ServerScriptService.ServerModules.MainModule:388: invalid argument #1 to 'insert' (table expected, got number)
I know this is a long post, but I am just frustrated with this.