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: Snow script won't stop dropping flakes

Previous Thread :: Next Thread 
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
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
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
11 Dec 2011 02:52 PM
bump

-Certified Idiot: Class 3.7
Report Abuse
Jagger19 is not online. 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
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
11 Dec 2011 02:59 PM
coroutine.yield(snow)

So it should stop :l
Report Abuse
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
11 Dec 2011 03:20 PM
bump

-Certified Idiot: Class 3.7
Report Abuse
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
11 Dec 2011 04:33 PM
bump

-Certified Idiot: Class 3.7
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
11 Dec 2011 04:42 PM
Use the disconnect method.
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
11 Dec 2011 04:42 PM
Use the disconnect method.
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
11 Dec 2011 04:42 PM
Use the disconnect method.
Report Abuse
PompeyTheGreat is not online. PompeyTheGreat
Joined: 10 Apr 2011
Total Posts: 5615
11 Dec 2011 04:45 PM
So like this?

snow:disconnect()

-Certified Idiot: Class 3.7
Report Abuse
DXPower is not online. 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
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