kinglime
|
  |
| Joined: 27 Jun 2008 |
| Total Posts: 2751 |
|
|
| 15 Jul 2013 07:38 PM |
First function I have every try'ed to use, help me please. It only inserts 1, does not do 35.
print("Started.") function moveClouds() while true do wait(.1) part.CFrame = part.CFrame + Vector3.new(0, 0, 2) end end for i = 1,35 do wait() print(i) part = Instance.new("Part") mesh = Instance.new("SpecialMesh") part.Parent = game.Workspace mesh.Parent = part part.Name = "Cloud "..i part.BottomSurface = "Smooth" part.BrickColor = BrickColor.new("White") part.Size = Vector3.new(5, 2.4, 13) part.Position = Vector3.new(0,150,0) part.CFrame = part.CFrame + Vector3.new(math.random(-1000,1000),math.random(100,200),math.random(-1000,1000)) part.Anchored = true Scale = math.random(25, 75) mesh.Scale = Vector3.new(Scale, Scale, Scale) mesh.MeshId = "http://www.roblox.com/asset/?id=111820358" mesh.TextureId = "http://www.roblox.com/asset/?id=111820961" print("Finished Cloud "..i) moveClouds() end print("Finished!") |
|
|
| Report Abuse |
|
|
kinglime
|
  |
| Joined: 27 Jun 2008 |
| Total Posts: 2751 |
|
| |
|
|
| 15 Jul 2013 07:47 PM |
The while true do loops are stacking.
'function moveClouds() while true do wait(.1) part.CFrame = part.CFrame + Vector3.new(0, 0, 2) end end'
You'd need to use a coroutine to run multiple. (Although be warned, it will cause insane lag. You are running 35 while true do loops with a wait of .1.)
local moveClouds=coroutine.wrap(function(part) --added a parameter. while wait(.1) do part.CFrame=part.CFrame+Vector3.new(0,0,2) end end)
now basically, call it like so !! AFTER CREATING THE PART !! .
for i=1, 35 do moveClouds(PART HERE) wait() --35 while loops running at once, i love lag end |
|
|
| Report Abuse |
|
|
|
| 15 Jul 2013 07:48 PM |
First off, 'part' isn't defined in the function. It doesn't work the way you're trying to do.
moveClouds(part) --stuff end
Then you do moveClouds(part) However, the while true do end is keeping the script from continuing. We fix this with coroutines.
coroutine.wrap(function() moveClouds(part) end)()
http://wiki.roblox.com/index.php/Coroutine_Tutorial http://wiki.roblox.com/index.php/Beginners_Guide_to_Coroutines http://wiki.roblox.com/index.php/Function_Dump/Coroutine_Manipulation |
|
|
| Report Abuse |
|
|
|
| 15 Jul 2013 07:50 PM |
"(Although be warned, it will cause insane lag. You are running 35 while true do loops with a wait of .1.)"
I wouldn't say /insane/ lag. Maybe a little lag. I've done over 40 while true do loops waiting 1/30 of a second and there wasn't much noticeable lag. |
|
|
| Report Abuse |
|
|
kinglime
|
  |
| Joined: 27 Jun 2008 |
| Total Posts: 2751 |
|
|
| 16 Jul 2013 01:05 AM |
I have been messing around with this sense I posted this for help.
I cants get anything to work... |
|
|
| Report Abuse |
|
|
baheeg
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 72846 |
|
| |
|
DrWaffler
|
  |
| Joined: 16 Sep 2011 |
| Total Posts: 4248 |
|
|
| 16 Jul 2013 01:09 AM |
Don't yell at KingLime.
He was the Bees Knees in 2008. He has 08er Respect.
Love me? Find me on Twitter! @DrWafflerRBLX |
|
|
| Report Abuse |
|
|
baheeg
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 72846 |
|
| |
|
kinglime
|
  |
| Joined: 27 Jun 2008 |
| Total Posts: 2751 |
|
|
| 16 Jul 2013 01:16 AM |
I am just going to use the script I pasted here to get the output. Seeing as I have no clue what to even try to make it work with that stuff.
So the plan here is to have 35 Clouds inserted into the game, and once they are inserted they move, like clouds do.
------Output------
Started. 1 Finished Cloud 1
----------------------
That is it, it works for one cloud then stops. |
|
|
| Report Abuse |
|
|
kinglime
|
  |
| Joined: 27 Jun 2008 |
| Total Posts: 2751 |
|
| |
|