Heres my code:

	local SaveData = GameData:GetAsync(player.UserId)
	
	if PlayerData[player.UserId] then
	GameData:SetAsync(player.UserId, PlayerData[player.UserId])
	    if not SaveData then
		    GameData:SetAsync(player.UserId, PlayerData[player.UserId])
	    else
		    local success, err = pcall(function()
			    GameData:UpdateAsync(player.UserId, function(OldData)
				local newValue = OldData or {
					Coins = 0,
					Gems = 0,
					Cbpc = {
						PerClick = 25,
						Cost = 500,
					},
					Items = {},
					Discovered = {},
				}

				return newValue
			    end) 
		    end)
		end
	end

1 comment

0

I highly recommend using DataStore2 or ProfileService depending on your needs or both like I do