Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I need help with a player points script?

Asked by
Asirix 15
10 years ago

Okay, so this is my problem, I am making a button where when you press, it's prompts the purchase of the product then afterwards awards players a certain amount of points based on the item bough. For example, 1,2,3,4, or 5 points. Here's my script. Any suggestions?

local MarketplaceService = Game:GetService("MarketplaceService")
local buyButton = script.Parent
local productId = 19714110
local PointsService = Game:GetService("PointsService")

function buy()
    MarketplaceService:PromptProductPurchase(player, productId)
        if ( pointsToAward > 0 and universeBalance == 0) then
            PointsService:AwardPoints(player.userId, 1)
        end
end

buyButton.MouseButton1Down:connect(buy)
0
http://www.roblox.com/Forum/ShowPost.aspx?PostID=131619603 There, SML said "That is why we have points. Yes, you can buy points, but I am not sure why anyone would waste the money on something that you can get for free playing games. " on page 21 Maxomega3 106 — 10y

1 answer

Log in to vote
0
Answered by
Dummiez 360 Moderation Voter
10 years ago

You're missing some declared variables, otherwise good try at it. It isn't recommended that players buy points however, which is against the context of Player Points.

If you want to change the number of points awarded based on what they buy, you can have your individual scripts on each button like this.

-- Needs to be a ServerScript, not Local.

local MarketplaceService = Game:GetService("MarketplaceService")
local PointsService = Game:GetService("PointsService")

local buyButton = script.Parent
local productId = 19714110
local player = script.Parent.Parent.Parent.Parent -- Parent as the player.

local pointsToAward = PointsService:GetAwardablePoints()
local universeBalance = PointsService:GetGamePointBalance(player.userId)

buyButton.MouseButton1Click:connect(function()
    MarketplaceService:PromptProductPurchase(player, productId)
    if ( pointsToAward > 0 and universeBalance == 0) then
        PointsService:AwardPoints(player.userId, 1)
    end
end)

If you one script to function multiple buttons of purchasing, then you would need to create multiple instances of buyButton.MouseButton1Click:connect(function() with buyButton as another variable name. It also should be in the same member of the buttons.

Ad

Answer this question