|
| 11 Dec 2011 02:31 PM |
I'm trying to make a sort of realistic snowfall script using the new fog. It works, kind of. It summons the fog, starts falling, and when the fog disappears, no flakes are removed and it doesn't stop snowing. The script doesn't break, because the fog still comes in and out, but like i said, it never stops snowing. Anyone see the problem?
----------
local density = 20 local timeBetween = 30 local fallLength = 40 local flakes = {} game.Lighting.FogEnd = 100000 game.Lighting.FogColor = Color3.new(221/255,221/255,221/255) density = math.ceil(density) print("Density changed to "..density) local snow = coroutine.create(function() local dropTemplate = Instance.new("Part") dropTemplate.BrickColor = BrickColor.new("Institutional white") dropTemplate.formFactor = "Custom" dropTemplate.Size = Vector3.new(.2,.2,.2) dropTemplate.Name = "Snowflake" while wait(.3) do local drop = dropTemplate:clone() drop.Position = Vector3.new( math.random(-100,100), 100, math.random(-100,100) ) drop.Parent = game.Workspace drop.Anchored = false drop.CanCollide = false vel = Instance.new("BodyVelocity",drop) vel.velocity = Vector3.new(0,-20,0) table.insert(flakes, drop) drop.Touched:connect(function() drop:remove() end) end end) while true do wait(timeBetween) game.Lighting.FogEnd = 1000 for i = game.Lighting.FogEnd, density, -5 do wait() game.Lighting.FogEnd = i end coroutine.resume(snow) wait(fallLength) for i = game.Lighting.FogEnd, 1000, 5 do wait() game.Lighting.FogEnd = i end coroutine.yield(snow) for i = 1, #flakes do flakes[i]:remove() end game.Lighting.FogEnd = 100000 end
-Certified Idiot: Class 3.7 |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 02:52 PM |
bump
-Certified Idiot: Class 3.7 |
|
|
| Report Abuse |
|
|
Jagger19
|
  |
| Joined: 14 Jun 2008 |
| Total Posts: 1877 |
|
|
| 11 Dec 2011 02:57 PM |
| Maybe because you used a while loop? That loop will never stop. |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 02:59 PM |
coroutine.yield(snow)
So it should stop :l |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 03:20 PM |
bump
-Certified Idiot: Class 3.7 |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 04:33 PM |
bump
-Certified Idiot: Class 3.7 |
|
|
| Report Abuse |
|
|
DXPower
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
|
| 11 Dec 2011 04:42 PM |
| Use the disconnect method. |
|
|
| Report Abuse |
|
|
DXPower
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
|
| 11 Dec 2011 04:42 PM |
| Use the disconnect method. |
|
|
| Report Abuse |
|
|
DXPower
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
|
| 11 Dec 2011 04:42 PM |
| Use the disconnect method. |
|
|
| Report Abuse |
|
|
|
| 11 Dec 2011 04:45 PM |
So like this?
snow:disconnect()
-Certified Idiot: Class 3.7 |
|
|
| Report Abuse |
|
|
DXPower
|
  |
| Joined: 21 Oct 2008 |
| Total Posts: 2866 |
|
|
| 11 Dec 2011 05:00 PM |
Try and find some event to use disconnect with, for this script, I suggest .Changed in the Lighting's fog...
Do this:
local connection = game.Lighting.(Put property here).Changed:connect(function() end)
script.Parent.Touched:connect(function() connection:disconnect() end)
More info on this topic: http://wiki.roblox.com/index.php/Disconnect_%28Method%29 |
|
|
| Report Abuse |
|
|