Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Give a Player Points when they buy a Developer Product?

I want to make it so when a Player BUYS a Developer Product, it gives them one point. But I am stuck on the part when it gives them it when they only BUY it:

-- 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)
	
	local PointsService = Game:GetService("PointsService")
 
	local pointsToAward = PointsService:GetAwardablePoints()
	local universeBalance = PointsService:GetGamePointBalance(player.userId)
	if ( pointsToAward > 0 and universeBalance == 0) then
		PointsService:AwardPoints(player.userId, 1) --Btw, do I change this to my ID?
	end
end)
 
PointsService.PointsAwarded:connect(function(userId, userBalanceinUni, userBalance)
	local message = Instance.new('Hint', game.Workspace)
	message.Text = "Point awarded to " .. userId .. ". This player now has " .. userBalance .. " points total!"
	wait(5)
	message:Destroy()
end)

1 answer

Here

-- 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)

    local PointsService = Game:GetService("PointsService")

    local pointsToAward = PointsService:GetAwardablePoints()
    local universeBalance = PointsService:GetGamePointBalance(player.userId)
    if ( pointsToAward > 23 and universeBalance == 0) then --23 or 1 or whatever
        PointsService:AwardPoints(player.userId, 1) --Id is fine
    end
end)

PointsService.PointsAwarded:connect(function(userId, userBalanceinUni, userBalance)
    local message = Instance.new('Hint', game.Workspace)
    message.Text = "Point awarded to " .. userId .. ". This player now has " .. userBalance .. " points total!"
    wait(5)
    message:Destroy()
end)

This should work...

This discussion is preserved as it was. New answers, comments, and votes are closed.