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

Player Points Help?

Asked by 10 years ago

04-26-2014 03:01 PM I have this script, but it won't award the Player Point to the player:

local buyButton = game.Workspace.Buttons.BuyButton.SurfaceGui.TextButton
local user = game.Players.LocalPlayer.userId
buyButton.MouseButton1Click:connect(function()
local productId = 19251902
Game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
local PointsService = Game:GetService("PointsService")
game.Players.LocalPlayer.leaderstats.Diamonds.Value = game.Players.LocalPlayer.leaderstats.Diamonds.Value + 10
PointsService:AwardPoints(user, 1)
end)

Everything is in a LocalScript, the purchase and the Diamonds work fine, but the points don't. Why

2 answers

Log in to vote
1
Answered by 10 years ago

You have to put it in a public script not a local. Local scripts execute locally and can't do some things.

0
So All I have to do is copy the answer above into a normal script? But wouldn't MarketPlaceService NOT run? I want to award the points right after the purchase. fahmisack123 385 — 10y
Ad
Log in to vote
0
Answered by
lomo0987 250 Moderation Voter
10 years ago

Try this.

local buyButton = game.Workspace.Buttons.BuyButton.SurfaceGui.TextButton
local user = game.Players.LocalPlayer.userId
buyButton.MouseButton1Click:connect(function()
local productId = 19251902
Game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
local PointsService = Game:GetService("PointsService")
local pointsToAward = PointsService:GetAwardablePoints()
game.Players.LocalPlayer.leaderstats.Diamonds.Value = game.Players.LocalPlayer.leaderstats.Diamonds.Value + 10
if  pointsToAward > 0 then
PointsService:AwardPoints(user, 1)
end)

Answer this question