|
| 30 Jun 2017 02:34 PM |
while wait(0.33) do local closest = scan() if closest then stats.Value = "Stage " .. closest + 1 end -- char.Humanoid.Died:connect(function() stats.Value = "Stage 1" end) -- end
Everything besides the loop itself is irrelevant, I want to know if hooking this loop up to a Heartbeat function will make the game lag, as it has to check a lot of parts every .33 seconds already |
|
|
| Report Abuse |
|
|
BaiYuni
|
  |
| Joined: 09 Oct 2009 |
| Total Posts: 2861 |
|
|
| 30 Jun 2017 02:37 PM |
Well putting the Heartbeat RunService will run as fast as the player's computer will let them.
What are you trying to do though? Is looping that the only way to get the outcome of what you want? |
|
|
| Report Abuse |
|
|
|
| 30 Jun 2017 02:39 PM |
'Well putting the Heartbeat RunService will run as fast as the player's computer will let them.'
True.
'What are you trying to do though? Is looping that the only way to get the outcome of what you want?'
I'm checking for a certain part in a randomly generated obby (a checkpoint), and it goes through all of the obbies to find the nearest one (the scan() function.)
Basically just iterates through a lotta parts |
|
|
| Report Abuse |
|
|
| |
|
nullfeels
|
  |
| Joined: 31 Mar 2017 |
| Total Posts: 1215 |
|
|
| 30 Jun 2017 03:13 PM |
I'm not entirely sure I understand correctly, but it sound like you just want to store the last checkpoint a player has reached.
Create a trigger zone around every checkpoint so the player has no choice but to pass through it, and then set their currentCheckpoint variable to the latest one.
Then on death just TP them to it.
Running that loop on a lot of parts would indeed cause some lag. Whether it would be noticeable or not just depends, bu it's still inefficient. |
|
|
| Report Abuse |
|
|