Hey fellow developers! I have been scripting for about 2 months now and was wondering, how to make a add stats on purchase thing.
Such as, if a player purchases a dev product it will add 500 coins to their stats. If you can possibly give me a link or a script I could use? This would be on a gui, not a part or a model.
Then create a script, so we can hook this prompt with the server.
game:GetService("MarketplaceService").ProcessReceipt = function(reciept) --Here we are hooking the client code with the server
for _, player in pairs(game.Players:GetPlayers()) do --Then we are looping through all the players in-game
if player.UserId == reciept.PlayerId and receipt.ProductId == productId then --If the player id is the same id of the player that purchased the product then we continue
--Add here where it add to player's stats
end
end
end
Adding to stats:
player.leaderstats["CurrencyNameHere"] += 0 -- Amount that you want to give player