What i’m trying to achieve is when a player joins the script finds the items it collected from last session (using ProfileService) which are saved in a table and then GETS those items from the Items list and places it inside a folder.
But when I run the game I get an error ServerScriptService.loadData:10: attempt to index nil with ‘collection’.
The error goes off at line 10, Help would be appreciated!
game.Players.PlayerAdded:Connect(function(player)
local provider = require(script.Parent.DataProvider)
local data = provider:Get(player)
table.foreach(data.collection,function(_,key)
game.Workspace.Cubes:FindFirstChild(key).Parent = player.cubesFound
print("Player_"..player.UserId.." had saved"..key.." from last session.")
end)
end)