Arrtizt
|
  |
| Joined: 13 Oct 2016 |
| Total Posts: 565 |
|
|
| 13 Jun 2017 11:20 AM |
By the way, I'm very new to scripting. I just started a few days ago, actually. I made a script for my obby, and I don't know how to make it loop. I can't find it online anywhere..
(I'm sorry, I was going to put the exact script, but it's all hashtagged. It's just a very long script. It's just making something completely transparent and non transparent smoothly.)
|
|
|
| Report Abuse |
|
|
TaaRt
|
  |
| Joined: 26 Apr 2009 |
| Total Posts: 5039 |
|
|
| 13 Jun 2017 11:22 AM |
| If you can't find it online anywhere, I'd start with a course 'google for beginners' |
|
|
| Report Abuse |
|
|
Arrtizt
|
  |
| Joined: 13 Oct 2016 |
| Total Posts: 565 |
|
|
| 13 Jun 2017 11:26 AM |
That's pretty rude. I have found stuff, but none of them worked, and they were all different things. Sorry for bothering you by asking a simple question. If you are going to respond to this, please either it be something that isn't completely rude, or an actual helpful answer.
|
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 13 Jun 2017 11:29 AM |
| 'roblox loop' first result: ############################################ |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 13 Jun 2017 11:29 AM |
| wow roblox filters roblox #### now huh. |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2017 11:30 AM |
| a loop is most likely not what ur looking for wiki.roblox.com/index.php?title=API:Class/RunService/Heartbeat wiki.roblox.com/index.php?title=API:Class/RunService/Stepped wiki.roblox.com/index.php?title=API:Class/RunService/BindToRenderStep wiki.roblox.com/index.php?title=API:Class/RunService/UnbindFromRenderStep if u want # ### # #### u should be using it for something other than running X infinitely |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2017 11:31 AM |
a loop is most likely not what ur looking for
wiki.roblox.com/index.php?title=API:Class/RunService/Heartbeat wiki.roblox.com/index.php?title=API:Class/RunService/Stepped
wiki.roblox.com/index.php?title=API:Class/RunService/BindToRenderStep wiki.roblox.com/index.php?title=API:Class/RunService/UnbindFromRenderStep
if u really want a loop then u should most likely only use them to run things at the same time or iterate through things, not to execute code forever |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2017 11:32 AM |
| wut up! this script should be in the part while true do for i = 0, ## ## ## ########################## = i wait() end for i = 1, ## ### ## ########################## = i wait() end end |
|
|
| Report Abuse |
|
|
| |
|
|
| 13 Jun 2017 11:33 AM |
wrong please learn how to use connections and not whatever this kid typed up this is bad practice |
|
|
| Report Abuse |
|
|
| |
|
Arrtizt
|
  |
| Joined: 13 Oct 2016 |
| Total Posts: 565 |
|
|
| 13 Jun 2017 11:39 AM |
ooo comment drama.. the intensity tho
( and thanks by the way :) )
|
|
|
| Report Abuse |
|
|
|
| 13 Jun 2017 11:44 AM |
bcuz u should not be using loops for such things, the connection is much convenient and should most likely be faster and a better solution to what u r trying to accomplish a while wait() loop is just for beginners who dont understand how to use connections or if u r waiting for something to appear such as
local char = player.Character while not char do wait() char = player.Character end --which then again can be superseded by local char = player.Character or player.CharacterAdded:wait() or when ur delay needs to be in seconds or such for like a server counter? but other than that there really is no use to be using a while loop instead of an event and it will only put u at a disadvantage |
|
|
| Report Abuse |
|
|
TaaRt
|
  |
| Joined: 26 Apr 2009 |
| Total Posts: 5039 |
|
|
| 13 Jun 2017 11:46 AM |
while wait() is pretty much exactly what the underlying code behind events does (no I'm not saying you should use that in Lua instead of the events, simply stating that the core of events is a C++ equivalent of while wait(), so the practice isn't per se malpractice) |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2017 11:49 AM |
ur incorrect as the events fire every server 'frame', every client 'frame' and on every step in the run service wait only fires for around 1/30 fps when the others fire much more and at a different rate |
|
|
| Report Abuse |
|
|
TaaRt
|
  |
| Joined: 26 Apr 2009 |
| Total Posts: 5039 |
|
|
| 13 Jun 2017 11:50 AM |
| that's the difference in the server running it and the client, I'm not sure how you hope to prove that the abstraction is incorrect by stating the results vary per machine |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2017 11:54 AM |
it is incorrect because it specifically said it fires at about 1/30th fps stepped does as well but the others fire at nearly 1/60 fps which is more than double and it will also automatically create a new thread so u dont have to make a coroutine if u wish to run something after initializing the 'loop' |
|
|
| Report Abuse |
|
|
TaaRt
|
  |
| Joined: 26 Apr 2009 |
| Total Posts: 5039 |
|
|
| 13 Jun 2017 11:55 AM |
| It's a state machine, if timestamp%60 run x, if timestamp%30 run y, else wait. The whole thing however runs on an undefined interval as it's determined by cpu cycles |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2017 05:30 PM |
while true do wait()
if script.Disabled == false then print('Will run forever')
else print("Won't run cuz' I'm not enabled (?)')
end end |
|
|
| Report Abuse |
|
|
Arrtizt
|
  |
| Joined: 13 Oct 2016 |
| Total Posts: 565 |
|
|
| 14 Jun 2017 02:09 PM |
I learned how to do what I wanted to do. I used the "while true do" method.
|
|
|
| Report Abuse |
|
|
|
| 14 Jun 2017 02:13 PM |
| When you use the while true do method just remember to out a wait in there or else your game will crash xD |
|
|
| Report Abuse |
|
|
|
| 14 Jun 2017 02:23 PM |
The issue with using connections to Heartbeat and RenderStepped is that it creates a new thread 30/60 -ish times per second, which puts unnecessary stress on the thread handler. Also, if your code in the connected function does not complete within the interval before the next step, it can end up overlapping, which is bad.
The better practice is to use BindToRenderStep, or in the case of Heartbeat, a 'while loop' with RunService.Heartbeat:Wait() as the yield. |
|
|
| Report Abuse |
|
|