Attempt to index nil with ' collection '

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! :happy3:

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)
local data = provider:Get(player)

Means this is nil.

Oh, I didnt notice it was a module error! :sweat_smile: