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)
Well, that loop is a bit inefficient. Try mine. The PlayerAdded Event fires when a player joins. If 2 join at one time, in your case, it'd get a bit mixed up.
PointsService = game:GetService("PointsService") while true do if not (PointsService:GetAwardablePoints() <= 2) then for i,plr in pairs(game.Players:GetChildren()) do PointsService:AwardPoints(plr.userId, 2) wait(5) end end end
The PlayerAdded
event does a function one time only when the player joins a server, you will need to use another event.
This will help: http://wiki.roblox.com/index.php?title=Player_Points
I can't help you much more because I am new to scripting.