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

Why won't it give Players Player Points if they are alive for 100 Seconds?

I want to make it when a Player is alive for 100 Seconds, they get 1 Point, but this doesn't work. Can anyone help me? It's in ServerScriptStorage.

players = game.Players:GetPlayers()

currency = "Seconds Alive"

for i=1,#players do
if players[i].leaderstats[currency].Value == 100 then
	
	local PointsService = Game:GetService("PointsService")
local pointsToAward = PointsService:GetAwardablePoints()
local universeBalance = PointsService:GetGamePointBalance(player.userId)
if ( pointsToAward > 0 and universeBalance == 0) then
	PointsService:AwardPoints(player.userId, 1)
	
end
end
end

PointsService.PointsAwarded:connect(function(userId, userBalanceinUni, userBalance)
	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)

1 answer

First, let's see if your game can even qualify for Roblox Points.

The Technical Definition:

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.

Right now, for every ROBUX sent, one point is generated. That is, if 100 ROBUX is spent, then 30 ROBUX is sent to ROBLOX and 70 ROBUX is sent to the user (presuming the user is BC), and thus, 30 points are generated.

Does you game make money? (In game purchases, Game Passes, etc..)

If your answer is no, stop here. Otherwise, keep following. Here you can see the AwardPoints Method. You would use that, and fire it whenever a player gets the required time.

Example scripts:

function GivePoints(User)
	local PointsService = Game:GetService("PointsService")
	PointsService:AwardPoints(User.userId, 2)
end

game.Players.PlayerAdded:connect(GivePoints)

As a Script for time

TimeRequired = 5  -- In minutes.

function GivePoints(User)
	local PointsService = Game:GetService("PointsService")
	PointsService:AwardPoints(User.userId, 2)
end

while wait(TimeRequired * 60) do
	GivePoints(script.Parent.Parent)
end

But be careful! A game has limited points to hand out to people.

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