How do I fix this issue with the script?

So I have this script (not local) which is inside a TextButton (when clicked, the purchase prompt for the developer product should appear):

local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
local link = game:GetService("MarketplaceService")
deb = 0


script.Parent.MouseButton1Click:connect(function()
		local marketId = 1301207378 -- Developer Product
	link:PromptProductPurchase(plr,marketId)
		link.ProcessReceipt = function(receiptInfo)
		if Enum.ProductPurchaseDecision.PurchaseGranted and receiptInfo.PlayerId == plr.userId then
				if deb == 0 then
					deb = 1
					plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 250 -- Amount added after purchase
					wait(1)
					deb = 0
				end
			end
		end
	end)

But for some reason when I click, nothing happens or appears, instead I get this error:
Screenshot_6

How do I fix this problem?

you should do

local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent.Parent.Parent.Parent)

if the script.Parent.Parent.Parent.Parent.Parent.Parent was the player’s character.
also why ru using “MouseButton1Click” event in a script that wouldn’t work.

you could fire a remote event to the server

local Remote = game.ReplicatedStorage.YourRemote
-- LocalScript
script.Parent.MouseButton1Click:connect(function()
       Remote:FireServer()
end)
-- ServerScript
local Remote = game.ReplicatedStorage.YourRemote
Remote.OnServerEvent:Connect(function(plr)
local marketId = 1301207378 -- Developer Product
	link:PromptProductPurchase(plr,marketId)
		link.ProcessReceipt = function(receiptInfo)
		if Enum.ProductPurchaseDecision.PurchaseGranted and receiptInfo.PlayerId == plr.userId then
				if deb == 0 then
					deb = 1
					plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + 250 -- Amount added after purchase
					wait(1)
					deb = 0
				end
			end
		end
end)

Like @ayoub50 said, this is not the player. You must either use a for loop to collect all players, or you use game.Players.LocalPlayer

Whats the market? Is it in Albuquerque? Asking for a friend.

If you want to use server scripts, you could use click detectors with .MouseClick instead because it has a player argument. You could also use local scripts and use local player to detect who clicked on the button.