Hello! I have been working on a new developer product for a game that I am making, in which the player can change their name tag color.
I have reviewed all of my code multiple times, and I’ve even compared it to code that works, however, this isn’t working what-so-ever. As of now, I have inserted some print functions to check what runs, but the process receipt itself doesn’t even activate.
If needed, I can post my code, but I don’t think my code is the issue.
All help is appreciated. Thank you!
Edit: When I say that I’ve compared it to other code, the ProcessReceipt callback looks exactly the same on both.
I made a print function originally before the ProcessReceipt and it still printed. When I purchased the developer product (the ids do match on both the client and server), the prints I had inside the callback didn’t run at all.
local nameTagColorFunction = Instance.new("RemoteFunction",game.ReplicatedStorage)
nameTagColorFunction.Name = "NameTagColorFunction"
local marketplaceService = game:GetService("MarketplaceService")
local nameTagProductId = 265127818
local donationsIdsConfig = require(workspace:FindFirstChild("Boards"):FindFirstChild("Products"))
local donationIds = donationsIdsConfig.Products
local donationsDataStore = game:GetService("DataStoreService"):GetOrderedDataStore("TopDonators")
local nameTagDataStore = game:GetService("DataStoreService"):GetDataStore("NameTagColor")
marketplaceService.ProcessReceipt = function(receiptInfo)
if receiptInfo.ProductId == nameTagProductId then
local color = nameTagColorFunction:InvokeClient(game.Players:GetPlayerByUserId(receiptInfo.PlayerId))
local s,m = pcall(function()
local plr = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
local character = plr.Character
character:FindFirstChild("Rank"):FindFirstChild("Frame"):FindFirstChild("Name1").TextColor3 = Color3.fromRGB(color[1],color[2],color[3])
character:FindFirstChild("Rank"):FindFirstChild("Frame"):FindFirstChild("TextLabel").TextColor3 = Color3.fromRGB(color[1],color[2],color[3])
end)
if s then
game.ReplicatedStorage:WaitForChild("color"):Fire(color,receiptInfo.PlayerId)
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
else
local id,value = getDonationId(donationIds,receiptInfo.ProductId)
local s,m = pcall(function()
donationsDataStore:IncrementAsync(receiptInfo.PlayerId,value)
end)
if s then
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
end```
I have no idea how I could’ve been so blind. I just found another script which utilizes process receipt (I thought it would give me an error saying that, but it never did).
(I develop this game with another scripter, who must’ve added that without letting me know).
Thank you for your help! Today is one of my off days.
There was no error because callbacks work very similar to properties, except they take a function as a value. You can re-assign it to a new function a billion times but it will only call the newest value, just like how reading properties only gives the newest value regardless if it was set to something previously.