Here is my datastore. It didnt save my data at all or print anything

local DataStoreService = game:GetService("DataStoreService")
local NewData = DataStoreService:GetDataStore("myDataStore")

game.Players.PlayerAdded:Connect(function(player)
	local data = Instance.new("Folder")
	data.Name = "data"
	data.Parent = player

	local eggs = Instance.new("IntValue")
	eggs.Name = "eggs"
	eggs.Parent = data

	local info
	local success, errormessage = pcall(function()
		data = NewData:GetAsync(player.UserId.."-eggs")
	end)

	if success then
		eggs.Value = info
	else
		print("There was an error whilst loading your data")
		warn(errormessage)
	end

end) 
game.Players.PlayerRemoving:Connect(function(player)
	local success, errormessage = pcall(function()
		NewData:SetAsync(player.UserId.."-eggs", player.data.eggs.Value)
	end)

	if success then
		print("eggs saved")
	else
		print("eggs not saved, error")
		warn(errormessage)
	end
end)

1 comment

0

Is it printing anything? And on line 13, you can try and say local data instead of info. Then on line 19, you can say eggs.Value = data I think it is important to say data instead of info because inside the pcall you are saying data