I have a datastore that saves a table and when I print the table result when the player loads it prints this: table: 19918444 and it is not a table as far as I can see. Could someone help me with this? If you need the script I will post it. Also the for loop that is supposed to loop through the table doesnt work. Hope you guys can help me. Thanks!
Edit 1. saving part:
game.Players.PlayerRemoving:Connect(function(plr)
if plr.CanSave.Value then
local specialKey = "User_"..plr.UserId
local plrName = plr.Name
local plrInfo = game.ServerStorage:FindFirstChild(plrName):WaitForChild("PlayerInfo")
if plrInfo.OwnsTycoon.Value then
local tycoonName = plrInfo.OwnedTycoon.Value
local tycoon = game.Workspace.Tycoons:FindFirstChild(tycoonName)
local moneyToSave = plrInfo.Money.Value
local buildLevelToSave = plrInfo.BuildLevel.Value
local purchasedItemsTable = getTableForDataStore(tycoon, plrInfo)
local mainTableToSave = {moneyToSave, buildLevelToSave, purchasedItemsTable}
local success, message = pcall(function()
mainDataStore:SetAsync(specialKey, mainTableToSave)
end)
end
end
end
loading part:
script.Parent.Touched:Connect(function(hit)
if script.Parent.CanCollide then
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid.Health > 0 then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
local plrName = plr.Name
local plrInfo = game.ServerStorage:FindFirstChild(plrName):WaitForChild("PlayerInfo")
local specialKey = "User_"..plr.UserId
local tycoon = script.Parent.Parent.Parent.Parent
local tycoonName = tycoon.Name
local mainDataTable
local serverTycoon = game.ServerStorage:FindFirstChild("Model"..tycoon.Color.Value.."Tycoon")
if not plrInfo.OwnsTycoon.Value then
if not tycoon.IsOwned.Value then
tycoon.IsOwned.Value = true
tycoon.Owner.Value = plrName
plrInfo.OwnedTycoon.Value = tycoon.Name
plrInfo.OwnsTycoon.Value = true
script.Parent.Transparency = 1
script.Parent.CanCollide = false
local success, message = pcall(function()
mainDataTable = mainDataStore:GetAsync(specialKey)
end)
if success then
print("Player Data Loaded Successfully")
plrInfo.Money.Value = mainDataTable[1] or 0
plrInfo.BuildLevel.Value = mainDataTable[2] or 1
local buildLevel = plrInfo.BuildLevel.Value
local baseplate = findBaseplate(buildLevel, serverTycoon)
local baseplateName = baseplate.Name
local tycoonBaseplate = tycoon:FindFirstChild("Baseplates"):WaitForChild(baseplateName)
local serverBaseplate = serverTycoon:WaitForChild(baseplateName)
local copy = baseplate.BaseplateEssentials:Clone()
copy.Parent = tycoon.Baseplates:FindFirstChild(baseplateName)
print(mainDataTable[3])
and the print at the end is what gives the output I set Please help!

1 comment
post code pl0x0rz