Help with saving a string value

I have a leaderstats datastore and on line 16 I get this error,

how can I fix it? Heres my code.

local DataStore =  game:GetService("DataStoreService"):GetDataStore("Rank")
game.Players.PlayerAdded:Connect(function(player)

	local leaderstats = Instance.new("Folder", player)
	leaderstats.Name = "leaderstats"
	local Gold = Instance.new("StringValue", leaderstats)
	Gold.Name = "Rank"
	-- Load data

	local data
	local key = "Player_".. player.UserId
	local success, errormessage = pcall(function()
		data = DataStore:GetAsync(key)
	end)
	if success then
		Gold.Value = data
	elseif data == nil then
		Gold.Value = "Citizen"
	else
		warn(errormessage)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local key = "Player_".. player.UserId

	local data = player.leaderstats.Rank.Value

	DataStore:SetAsync(key, data)
end)

GetAsync doesn’t always error if nil is returned (eg. if the player is new), so you have to handle that separately.