generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Question about loops

Previous Thread :: Next Thread 
Negativize is online. Negativize
Joined: 02 May 2011
Total Posts: 25068
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 is not online. 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
Negativize is online. Negativize
Joined: 02 May 2011
Total Posts: 25068
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
Negativize is online. Negativize
Joined: 02 May 2011
Total Posts: 25068
30 Jun 2017 02:54 PM
b
Report Abuse
nullfeels is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image