Underlines on some words

Underlines on some words throughout the script. How can I fix this?
image

I think it’s because the variables you created are out of the loop. Turn the variables you created into global variables by placing a _G. at the beginning of it.

so first you have

for  i = 1,#palyers  do
    -- your code here
end

you need to define players first (as a list, table)

after the first block of code you have an end that closes the function. get rid of that and receiptinfo should be good

return Enum.ProductPurchase-- blah blah
end

I’m trying to make these dev products in one script because apparently it like breaks if they aren’t in one script so like is this how I’m suppose to be doing it and yes I fixed those few lines expect there’s a few I still need to do.


function ReceiptHandler()
warn("Donation Board: ProcessReceipt Activated")
	game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
		local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
		local numberBought = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory"):IncrementAsync(playerProductKey, 1)
		local ProductBought = game:GetService("DataStoreService"):GetDataStore("PurchaseHistoryCount"):IncrementAsync(receiptInfo.ProductId, 1)
		local PlayerFound = false
		local players = game.Players.LocalPlayer
		local done = 0
		
		for i=1,#players do
			if players[i].userId == receiptInfo.PlayerId then
				if receiptInfo.ProductId == 1086221671 and done == 0 then
					done = 1
					players[i].leaderstats.Stage.Value = players[i].leaderstats.Stage.Value + 1
					players[i]:LoadCharacter()
					done = 0
				end
			end
		end
		return Enum.ProductPurchaseDecision.PurchaseGranted
		end

		for i, v in pairs (game.Players:GetChildren()) do
			if v:IsA('Player') then
				if v.userId == receiptInfo.PlayerId then
					for _, p in pairs (Products.Products) do
						if p.ProductId == receiptInfo.ProductId then
							if v ~= nil then
								PlayerFound = true
								game:GetService("DataStoreService"):GetOrderedDataStore(GetData()):IncrementAsync(receiptInfo.PlayerId, p.ProductPrice)
							end
						end
					end
				end
			end
		end
		if PlayerFound ~= true then
			return Enum.ProductPurchaseDecision.NotProcessedYet 
		else
		return Enum.ProductPurchaseDecision.PurchaseGranted		
	end
end
function ReceiptHandler()
warn("Donation Board: ProcessReceipt Activated")
	game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
		local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
		local numberBought = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory"):IncrementAsync(playerProductKey, 1)
		local ProductBought = game:GetService("DataStoreService"):GetDataStore("PurchaseHistoryCount"):IncrementAsync(receiptInfo.ProductId, 1)
		local PlayerFound = false
		local players = game.Players.LocalPlayer
		local done = 0
		
		for i=1,#players do
			if players[i].userId == receiptInfo.PlayerId then
				if receiptInfo.ProductId == 1086221671 and done == 0 then
					done = 1
					players[i].leaderstats.Stage.Value = players[i].leaderstats.Stage.Value + 1
					players[i]:LoadCharacter()
					done = 0
				end
			end
		end
		return Enum.ProductPurchaseDecision.PurchaseGranted

		for i, v in pairs (game.Players:GetChildren()) do
			if v:IsA('Player') then
				if v.userId == receiptInfo.PlayerId then
					for _, p in pairs (Products.Products) do
						if p.ProductId == receiptInfo.ProductId then
							if v ~= nil then
								PlayerFound = true
								game:GetService("DataStoreService"):GetOrderedDataStore(GetData()):IncrementAsync(receiptInfo.PlayerId, p.ProductPrice)
							end
						end
					end
				end
			end
		end
		if PlayerFound ~= true then
			return Enum.ProductPurchaseDecision.NotProcessedYet 
		else
		return Enum.ProductPurchaseDecision.PurchaseGranted		
	end
end

also why for i =1, #players when players = game.Players.LocalPlayer(one entity)

For is underlined here on this line.

the problem there is the return that is in front of it. since i don’t know what are you trying to achieve with that return i can’t point any more problems for now

This is because of type checking. Also you cannot use process recepit on the client, it is a service side function.

If you want to disable type checking add --!nocheck to the top of your script.

1 Like

Well, from previous posts people are saying I have to put a receipt in one function. Therefore I’m putting two products in one function.

So how would I change it to a server side function?