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

How do i make it award 1 point on the game leader board every time someone visits my game?

Asked by 6 years ago

I'm not trying to make it award points inside the game, just on the leader board outside the game.

1 answer

Log in to vote
1
Answered by 6 years ago

This code is untested but try this out. Let me know if you get any errors!

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

-- Bind function to player added event
game.Players.PlayerAdded:connect(function(player)
    -- Get total number of points this game has already awarded to the player
    local universeBalance = PointsService:GetGamePointBalance(player.userId)
    -- Check if the player hasn't gotten any points yet. If true, award the points.
    if ( 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')
    message.Text = "Point awarded to " .. userId .. ". This player now has " .. userBalance .. " points total!"
    message.Parent = workspace
    wait(5)
    message:Destroy()
end)
0
I just want it to award points every time someone visits my game secretly so i can see how many times they've visited, Also i'm getting an error on line 10. QuantumScripter 48 — 6y
0
It's not posting to the leader board but it is rewarding me 1 point. QuantumScripter 48 — 6y
Ad

Answer this question