So I have a game where a person gets 2 player points every 5 seconds. It was working at first, and then all of a sudden during the game it will randomly stop working. I notice it stops working most often when multiple people join the game. Its a simple script and I'm not sure why it breaks so easily. I was thinking to fix it maybe there were some lines I could add to make it reset or start over every minute in case it stops working.
PointsService = game:GetService("PointsService")
game.Players.PlayerAdded:connect(function(p)
while true do
wait(5)
game:GetService("PointsService"):AwardPoints(p.userId,2)
print("Point awarded!")
end
end)

10 comments
I like your answer that's what I'm looking for except I just tried that script and it wasn't awarding any points.
Could you give me the error? In-game, press F9, go to server console, and tell me what's wrong.
His loop is in no way "inefficient" (other than maybe substituting the
truewithwait(5)). His would work just as fine as yours would, and would work accordingly; every 5 seconds after a player joins they receive 2 points.@18, Sorry. Bit wrong choice of words.
Ok so Im not sure which one is the error but Ill tell you most of what it says :
Well Im guessing the error is the two red lines. The first says "-- Workspace. PointScript:3: attempt to compare boolean with number." Also a few lines later it says something about Line 3 so Im guessing that it where the error is in the script? The second place where it has a red line is right after I was added it says "WaitforChild called on an Instance that is not in a DataModel."
Oh, fail. I realized why. Try now
Try what?
My script. I edited it.
Oh oh thanks I'm still new to this site.