im currently creating a datatstore system that saves a table and these errors are coming out. im currently using a modulescript for the savedata and getdata functions:
function module.saveData(plr: Player, dataStore: DataStore, keyAddition:string, dataToSave)
local success, err = pcall(function()
print(keyAddition.."<br>"..dataToSave)
dataStore:SetAsync(plr.UserId..keyAddition, dataToSave)
end)
if success then
print("Successfully saved Data.")
else
warn(err)
end
end
function module.getData(plr: Player, dataStore: DataStore, key)
local data = {}
local success, err = pcall(function()
data = dataStore:GetAsync(plr.UserId..key)
end)
if success and data ~= nil then
return dataStore
elseif not success then
warn(err)
else
print("Player is new. Creating new Data")
end
end
when i call these functions they print a warning:
ReplicatedStorage.Data/Tables:35: attempt to concatenate number with nil
ReplicatedStorage.Data/Tables:20: attempt to concatenate string with table
Concatenating is linking multiple sets of characters together into one. In Lua, you can only concatenate strings and numbers. You can concatenate two variables by joining them together with a ..
print(keyAddition.."<br>"..dataToSave)
Since dataToSave is a table, Roblox throws an error when you try to concatenate it. The second error âattempt to concatenate number with nilâ is most likely a result of keyAddition not existing, therefore it returns nil.