Datastore returns nil values

Hi developers,

I have a script where it saves the appearance of a character, and it returns nil when I print it. Can anyone help with this?

In my serverscript:

dataStore = game:GetService("DataStoreService")

appearanceData = dataStore:GetDataStore("AppearanceData")
weaponData = dataStore:GetDataStore("WeaponData")

updateAppearance = function(plr, data)
	game.ReplicatedStorage["Load Appearance"]:FireClient(plr, "appearance", data)
end
updateWeapon = function(plr, data)
	game.ReplicatedStorage["Load Appearance"]:FireClient(plr, "weapon", data)
end

game.Players.PlayerAdded:Connect(function(playerAdded)
	plr = "player_"..playerAdded.UserId
	local success, errormessage = pcall(function()
		aprdata = appearanceData:GetAsync(plr)
		wpndata = weaponData:GetAsync(plr)
	end)
	if success then
		updateAppearance(playerAdded, aprdata)
		updateWeapon(playerAdded, wpndata)
	end
end)

game.ReplicatedStorage["Save Data"].OnServerEvent:Connect(function(plr, appearancedata, weapondata)
	plr = "player_"..plr.UserId
	local success, errormessage = pcall(function()
		appearanceData:SetAsync(plr, appearancedata)
		weaponData:SetAsync(plr, weapondata)
	end)
end)

And in a localscript:

game.Players.PlayerRemoving:Connect(function(plr)
	if plr == game.Players.LocalPlayer then
		if plr == game.Players.LocalPlayer then
			if hairAndHeadgear == nil then
				hairAndHeadgear = "hair1"
			end
			if shirt == nil then
				shirt = "shirt1"
			end
			if pants == nil then
				pants = "pants1"
			end
			if face == nil then
				face = "face1"
			end
		end
		local appearancedata = "-"..hairAndHeadgear.."-"..shirt.."-"..pants.."-"..face
		local weapondata = "-"
		game.ReplicatedStorage["Save Data"]:FireServer(appearancedata, weapondata)
	end
end)

hi mate can you show us the output ?

I have a script that prints it as well if this helps:

game.ReplicatedStorage["Load Appearance"].OnClientEvent:Connect(function(dataType, data)
	print(dataType)
	print(data)
end)

output

Edit: I’ve turned it into a table, but the value is still nil.