Why is it saying that playerName is a number and cant index findFirstChild

local function giftHandler()
	local function giftPurchaseFinished(player, purchaseID, status)
		if status == true then
			print(player)
			local playerName = game.Players:GetPlayerByUserId(player)
			print(playerName.Name)
			local playerToGift = playerName:FindFirstChild("OtherStats"):FindFirstChild("GiftTo").Value
			if purchaseID == 3370668881 then
				local playerToGiftName
				for i, player in ipairs(game.Players:GetPlayers()) do
					if player.UserId == playerToGift then
						playerToGiftName = player.Name
						print(playerToGiftName.." Got gifted gamepass")
					end
				end
				local val = Instance.new("StringValue",playerToGiftName:FindFirstChild("OtherStats"):FindFirstChild("Gamepasses"))
				val.Name = "X2Seeds"
			end
			playerName:FindFirstChild("OtherStats"):FindFirstChild("GiftsGiven").Value += 1
			print("Finished")
		end
	end
	MPS.PromptProductPurchaseFinished:Connect(giftPurchaseFinished)
	remotes.GiftRemote.OnServerEvent:Connect(function(playerGifting, playetToGift)
		if playerGifting:FindFirstChild("OtherStats"):FindFirstChild("GiftTo") then
			local GiftToID = game.Players:GetUserIdFromNameAsync(playetToGift)
			playerGifting.OtherStats.GiftTo.Value = GiftToID
		end
	end)
end

it says this line is erroring because it cant index a number with FindFirstChild

local playerToGift = playerName:FindFirstChild("OtherStats"):FindFirstChild("GiftTo").Value

Also the prints arent working in that either

Does it print playerName.Name?

It does not print playerName.Name

What does it do then instead? Does it print nil?

It doesnt print at all, I can omly test this in game but it doesnt print in the developer console

But it errors? So that I assume means that the scirpt didn’t find a player?