I want to make it so when you click a Brick with a SurfaceGui in the Workspace, it prompts a purchase. But I want it so when the player purchases the developer product, it pops up with a Hint saying "(Player) has bought (Name of item)!" and it gives them the ammount of points it's set for. In short terms: When a player clicks a surfaceGUI with a textbutton and when they purchase it, it will give them player points. Here is the script I have, please help me out by making it add Player Points when they buy it, comments in the script will be helpful.
-- setup local variables local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton local productId = 19700135 -- when player clicks on buy brick promt him/her to buy a product buyButton.MouseButton1Click:connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId) end)
--[[Edit "CURRENCY" with the game currency you want to award. You can also change 10 to the amount you want to award]] local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton local user = game.Players.LocalPlayer.userId buyButton.MouseButton1Click:connect(function() local productId = 19700135 Game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId) local PointsService = Game:GetService("PointsService") game.Players.LocalPlayer.leaderstats.CURRENCY.Value = game.Players.LocalPlayer.leaderstats.CURRENCY.Value + 10 PointsService:AwardPoints(user, 1) end
I will need to edit this soon, since this works on a LocalScript, without the Player Points. Once I found a solution, I will edit.