✓ Accepted answer
You can't use MarketplaceService on a LocalScript, or in a player since some weird things may happen. ProcessReceipt can only be used in one script, or else it will glitch out. It's like a bunch of players respawning and it keeps on triggering "ProcessReceipt" since it's in a GUI element.
So, you need to make it separate scripts, the button script on the button and the one that runs ProcessReceipt somewhere else, that will only make it run once.
So, here's a step by step process on how to fix it:
- Insert a LocalScript in the button
- Put this code in the button:
local button = script.Parent
local mpService = game:GetService('MarketplaceService')
button.MouseButton1Down:connect(function()
mpService:PromptProductPurchase(game.Players.LocalPlayer, 217674504 )
end)
3 & 4: Insert a Script in "ServerScriptService" & Put this code in the Script:
local mpService = game:GetService('MarketplaceService')
function mpService.ProcessReceipt(receiptInfo)
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if receiptInfo.ProductId == 217674504 then
player.leaderstats.Shillings.Value = player.leaderstats.Shillings.Value + 100
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
And you're done! :)
This has been tested, and it works.
DO NOT keep on duplicating the script in "ServerScriptService" to put more codes in, or else it will glitch.
1 comment
Thats great thank you, i'll be adding you name to the credits for the scripting help, cheers mate.