KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 19 Sep 2013 11:04 PM |
I don't have a laggy computer. It's generaly very fast.
I'm working on getting a script to spawn some basic parts for me every five seconds, and whenever I try playing it in Studio, I just crash.
It's not complete by the way.
while true do function onBox (boxy) Instance.new("Part",boxy,script.Parent) wait(5) end end |
|
|
| Report Abuse |
|
|
|
| 19 Sep 2013 11:05 PM |
Too many errors.
while true do function onBox(boxy) Instance.new("Part",boxy) end boxy(); wait(); end |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 19 Sep 2013 11:12 PM |
Thanks, it doesn't crash.
Nor does it work. Apparently, global "boxy" is a nil value. But isn't it the new part being generated? |
|
|
| Report Abuse |
|
|
|
| 19 Sep 2013 11:26 PM |
Do you really need it as a function?
while wait(5) do Instance.new("Part",Workspace).Position = Workspace.BasePlate.Position end |
|
|
| Report Abuse |
|
|
|
| 19 Sep 2013 11:27 PM |
| @OP, you need to set boxy's argument. |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 20 Sep 2013 08:40 AM |
I thought that would be this (Which doesn't work):
boxy = script.Parent
while true do function onBox(boxy) Instance.new("Part",boxy) end boxy(); wait(5); end |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 20 Sep 2013 08:41 AM |
| Unless..Have I not called the function? |
|
|
| Report Abuse |
|
|
lupine
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 3561 |
|
|
| 20 Sep 2013 09:09 AM |
also you don't have to do 'while true do'
while wait() do saves lines and space. |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 20 Sep 2013 05:34 PM |
Still doesn't work though. Doesn't "boxy()" call the function?
boxy = script.Parent
while wait(5) do function onBox(boxy) Instance.new("Part",boxy) end boxy() end |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 20 Sep 2013 05:39 PM |
onBox() calls the function. Not boxy(). And while I'm at it, its never smart to define a function INSIDE a while loop. Nor in this case do you need the argument boxy inside onBox. function onBox() is fine. Simply because in the function's parenthesis, it gives a new name to whatever is inside the parenthesis. So for instance,
function add(a, b) print(a+b) end
k = 2 l = 5 add(k, l)
In the function, a = k = 2, b = l = 5. It should print 7. Hope this helps. Now the actual script should be.
boxy = script.Parent
function onBox() Instance.new("Part",boxy) end
while wait(5) do onBox() end |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2013 05:59 PM |
basically the same script you had, but just change
boxy()
to
onBox() --the name of the function you are trying to call
|
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 20 Sep 2013 06:32 PM |
| I had to change a lot of stuff, but ended up getting it working. Just need to work on getting randomized properties now. |
|
|
| Report Abuse |
|
|
08C
|
  |
| Joined: 26 Jan 2013 |
| Total Posts: 847 |
|
| |
|
|
| 20 Sep 2013 06:57 PM |
| while true do means a continuous loop, which will cause studio to crash |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 20 Sep 2013 06:58 PM |
| Airplane, I've used plenty of scripts with while true do, they've never caused it to crash before. |
|
|
| Report Abuse |
|
|
|
| 20 Sep 2013 07:00 PM |
| oh, that's only with the print() command then |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Sep 2013 07:12 PM |
No.
You CAN do while true do anytime, as long as there is someway for it to "pause."
If you just plain: while true do end
Then it will crash the game. |
|
|
| Report Abuse |
|
|