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 » Scripting Helpers
Home Search
 

Re: Why does this function mess the script up?

Previous Thread :: Next Thread 
kinglime is not online. 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 is not online. kinglime
Joined: 27 Jun 2008
Total Posts: 2751
15 Jul 2013 07:45 PM
sdf
Report Abuse
Unsubstantial is not online. Unsubstantial
Joined: 11 Sep 2012
Total Posts: 872
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
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
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
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
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 is not online. 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 is not online. baheeg
Joined: 19 Jul 2010
Total Posts: 72846
16 Jul 2013 01:07 AM
[ Content Deleted ]
Report Abuse
DrWaffler is not online. 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 is not online. baheeg
Joined: 19 Jul 2010
Total Posts: 72846
16 Jul 2013 01:10 AM
[ Content Deleted ]
Report Abuse
kinglime is not online. 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 is not online. kinglime
Joined: 27 Jun 2008
Total Posts: 2751
16 Jul 2013 11:46 AM
Bump
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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