Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 answer

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)

2 comments

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.

0

It's not posting to the leader board but it is rewarding me 1 point.

This discussion is preserved as it was. New answers, comments, and votes are closed.