Maybe i could use a for loop and then make it so it only does something if it finds the Items value. Otherwise goes onto the next folder. Could this be a good idea?
ye sure but then what if it checks the other ones first, like other stats and player gui
I wrote this but it still doesnāt give an item
local function onProductPurchased(player, productId, isPurchased)
for i, v in pairs(player:FindFirstChild("leaderstats")) do
if v:FindFirstChild("Items") then
local Items = v:FindFirstChild("Items")
Items = Items + itemAmount
end
end
end
i got an idea, give leaderstats a tag using collectionservice, then make it so when they join it goes through the player and if the name is leaderstats and it doesnt have tag, then it destroys
How would i go about doing that? Oh yeah and a little note. I added a print statement but it didnāt print so maybe it canāt find the folder at all?
Oh wait i found something more! It doesnāt even enter the onProductPurchased function. So smth bout this is wrong:
MarketplaceService.ProcessReceipt = function(receiptInfo)
print("ProcessReceipt triggered!") -- Debugging line
-- Print receiptInfo details for more context
print("Receipt Info: " .. tostring(receiptInfo.ProductId) .. " - " .. tostring(receiptInfo.PlayerId))
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if player then
-- Log player's name and receipt product ID for context
print("Player found: " .. player.Name)
-- Call the function to grant the items
onProductPurchased(player, receiptInfo.ProductId, true)
-- Return Purchase Granted status
return Enum.ProductPurchaseDecision.PurchaseGranted
else
-- If player not found, log this for debugging
print("Player not found: " .. tostring(receiptInfo.PlayerId))
end
-- If the receipt couldn't be processed, return not processed yet
return Enum.ProductPurchaseDecision.NotProcessedYet
end
idk im not experienced with purchases being this complex. wait lemme just read it
I read somewhere that it might have something to do with having more than 1 script handling everything. Since i also have kill all and others that might be the problem?
um i dont think so one of ur scripts is making leaderstats or im blind
No i mean 1 script handling every process reciept?
ye maybe
char limit is annoying
Did you find anything in the function i sent?
um no i cant find anything idk why theres 2
Hmmm but i donāt think thatās the problem right now. The problem is that it never plays the onProductPurchased so smth is wrong in the part i sent.
.
.
.
.
did you even read my reply?
did you even consider reading it?
did you even consider trying my solution?
you fire a remote event, and prompt the purchase on the client, NOT on the server
what does this mean?
that the server DOESNāT know the purchase was prompted, thus it will not act whenever the player purchases it without the use of a remote event
AND EVEN IF YOU DO USE A REMOTE EVENT, YOU STILL NEED TO PASS THE RECEIPT INFO
AND AS FAR AS IāM CONCERNED, THEREāS NO WAY TO VERIFY RECEIPT INFO THAT GETS SENT FROM THE CLIENT
WHAT DOES THIS MEAN?
THAT EXPLOITERS WILL BE ABLE TO GET GAMEPASSES, OR EVEN DEV PRODUCTS FOR FREE
the amount of ignorance is ridiculous
i canāt believe this post is still ongoing
you wrote āMarketplaceService.ProcessReceipt = function(receiptInfo)ā, its just supposed to be āMarketplaceService.ProcessReceipt = receiptInfoā
sorry didnt see this,
do you use āProcessReceiptā in any other scripts?
ProcessReceipt can only be used by one script
Jesus thereās no reason to get that mad just because I missed 1 reply. I simply didnāt see your post at the time but I did the changes and it doesnāt work.
Yeah that was what I was wondering earlier. I have a bunch of buttons each with different amounts and the script is the same for all of them. So what you are saying is that i should just add a processreciept under 1 server script that then handles everything? Iāll try and see if that works.
Yeah, ProcessReceipt
can only be assigned to once by a server script. Other times will overwrite previous callbacks.
Thereās a good way on the Roblox documentation about it (I tweaked it a bit):
local productFuncs = {}
--add one of these for every product
productFuncs[productId] = function(player: Player)
--what you want to do in terms of giving player stuff for buying product here
end
--now the main process
game:GetService("MarketplaceService").ProcessReceipt = function(info: {[string]: any}): Enum.ProductPurchaseDecision
local player = game:GetService("Players"):GetPlayerByUserId(info.PlayerId)
local callback = productFuncs[info.ProductId]
local success = pcall(callback, player)
return (if success then Enum.ProductPurchaseDecision.PurchaseGranted else Enum.ProductPurchaseDecision.NotProcessedYet)
end