The players.PlayerAdded() event spawns a new task on the server every time it is called. The loop would only run in 1 task, meaning that it would be fine if multiple players join. There might be issues with performance if there are large amounts of players on each server, but it shouldn’t cause serious lag.
Also, just something I noticed, doing:
while true and task.wait(1) do
The true part of that line is redundant. You can instead just do:
I’ve seen a good amount of people say that task.wait(1) is more efficient
never have I done any sort of tests to prove this myself but i just got into habit to use task.wait()
this deserves to be shamed for i cannot read to save my life LOL
yes sure use task.wait(1) i tested difference between wait() and task.wait() wait is not waiting correctly.something like 1.2 seconds but task.wait(1) actually waits like 1.0 seconds
You should use the first option if you have a conditional statement, in place of “true”, that will be false at some point. Otherwise, as @Fittergem1000 stated, you should just use the second option.
im not choosing favotires for the solution I chose just wanted to say this cause you also helped the other persons response is helpful for more people since its a bit more in depth answer
<3 thanks for respond
Your solution provides a loop for a global reward system. The system that @bbnoshanky has in place is fired upon a player joining (players.PlayerAdded()). The player is already defined in the function and the server is only managing the specific player that joined. This happens every time a new player joins, that way each player gets their own reward loop.