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

How to award Player Points to a player?

Asked by 9 years ago

Can you tell me how to award PP to a player? (1 KO = 10 PP)

2 answers

Log in to vote
1
Answered by 9 years ago
PointsService = game:GetService("PointsService")
Stat = "KOs" --Change to the stats name
Needed = 10 --Change to the amount needed to get the playerpoints.
game.Players.PlayerAdded:connect(function(p)
repeat wait() until p:FindFirstChild("leaderstats") ~= nil
print("Found \"leaderstats\" object!")
repeat wait() until p.leaderstats:findFirstChild(Stat) ~= nil
print("Found "..Stat.." object!")
p.leaderstats[Stat].Changed:connect(function(prop)
print("Value changed!")
if prop >= Needed then
game:GetService("PointsService"):AwardPoints(p.userId,1)
end
end)
end)
--may not be the one ya want cause if yr kos is 10 r more, then pp awarded.

Get in touch with me in Xbox Live, ColinSantos8. Get in touch with me at ROBLOX,

Ad
Log in to vote
0
Answered by 9 years ago

http://wiki.roblox.com/index.php?title=Player_Points

Each game in ROBLOX has a budget of points that can be distributed to its players. Points are added to the budget every time a player makes a purchase in the game with Robux. Spending Robux includes buying game passes and developer products. A server script can check on the available balance of points in a game with the GetAwardablePoints() function. This function simply returns how many points are currently available to distribute to players.

Currently 30 points are generated per every ROBUX sunk in a game. For example, if a Developer Product is sold for 10 ROBUX, the game would get 300 points added to its budget.

This sample will give a point to a player when he or she joins the game. The point will only be awarded if the game has points to give and if the player has not gotten any points in the game yet.

-- declare service
local PointsService = Game:GetService("PointsService")

-- Bind function to player added event
game.Players.PlayerAdded:connect(function(player)
    -- Get total number of points the game has available
    local pointsToAward = PointsService:GetAwardablePoints()
    -- Get total number of points this game has already awarded to the player
    local universeBalance = PointsService:GetGamePointBalance(player.userId)
    -- Check if the game has points to award and if the player hasn't gotten any points yet. 
    -- If both are true, then give the player a point.
    if ( pointsToAward > 0 and universeBalance == 0) then
        -- pcall here, as AwardPoints *will throw an error* if another server has awarded the
        -- points that were available between us checking how many were available and
        -- us actually awarding the points. There is currently no way to avoid this pcall,
        -- whenever you AwardPoints you should always wrap it in a pcall.
        pcall(function()
            PointsService:AwardPoints(player.userId, 1)
        end)
    end
end)

-- Bind function to when points are successfully awarded
PointsService.PointsAwarded:connect(function(userId, userBalanceinUni, userBalance)
    -- Show message indicating that a player has gotten points
    local message = Instance.new('Message', game.Workspace)
    message.Text = "Point awarded to " .. userId .. ". This player now has " .. userBalance .. " points total!"
    wait(5)
    message:Destroy()
end)
0
Lua's admin also allows you to award PP's ultimate055 150 — 9y

Answer this question