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

How can I give player points to Guests? Or exclude them?

I have noticed that when a Guest is in my game the script awarding playerpoints will freeze because the GuestID has an id<=0 ....how can I resolve this? Do I add some exception for Guests somewhere? This should be built in by Roblox.

This is what my code looks like

			local PointsService = game:GetService("PointsService")
			local universeBalance = PointsService:GetGamePointBalance(randomplayer.userId)
			PointsService:AwardPoints(randomplayer.userId, 10)

1 comment

0

It's not bad to exclude the guest, since they can not keep their PlayerPoints. Just create a random number ABOVE 0, So code should look something like this, if randomplayer.userId > 0 then -- award code.

2 answers

✓ Accepted answer

Using an if statement this an be accomplished in seconds.


if player.UserId>0 and player.AccountAge>0 then
	local PointsService = game:GetService("PointsService")
	local universeBalance = PointsService:GetGamePointBalance(player.userId)
	PointsService:AwardPoints(randomplayer.userId, 10)
end

OR


local PointsService = game:GetService("PointsService")
local universeBalance = PointsService:GetGamePointBalance(player.userId)
if randomplayer.userId>0 and randomplayer.AccountAge>0 then
	PointsService:AwardPoints(randomplayer.userId, 10)
end

2 comments

0

AccountAge isn't really needed, since a Guest's ID is always a 0.

0

Encase roblox removes something or changes something.

You could do this to award points if the player is not a guest.

if Game.Players.LocalPlayer.Name:Sub(1,6) == "Guest" then
--Nothing
else
--Award Points
end

Hopefully this helped.

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