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

How do i give player points to a player when the player enters the game?

Asked by 10 years ago

How do i give player points to a player when the player enters the game?

1 answer

Log in to vote
0
Answered by
lomo0987 250 Moderation Voter
10 years ago
-- 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
        PointsService:AwardPoints(player.userId, 1)
    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)

I got the script and you can review more information about them here: http://wiki.roblox.com/index.php?title=Points_tutorial

0
Do you need player points to give the player points?And also one more question does it take one player point away form you and gives it to the player who earned it? iluvmaths1123 198 — 10y
Ad

Answer this question