Random Fog Script

Hello, i’m trying to make a Script that’s generate Fog across the Map/Game randomly like math.random(120, 240). But i dont now how to trigger or generate the Fog. Does Somebody can help :smiley: ?

Well, it depends on the scenario you could be going for

Are you wanting to change the Fog from inside the Lighting Service? Or are you wanting to create separate Fog Particles that will all be positioned in random spots?

Ye i wanna change the Fog from the Lighting. I guess thats the Roblox Fog so ye.

Basically the old nostalgic Fog yes lol

You could just set the FogEnd property to determine the visual radius of how far you can see on a Server Script:

game.Lighting.FogEnd = math.random(120,240)

If you wanted, you could also mess around with the properties of the fog by changing its Color & FogStart properties as well

game.Lighting.FogColor = Color3.fromRGB(125, 0, 0) --Very spooky red
1 Like

Ah that helps alot. But my last Question then is how do i loop it (while true do) . So lets say i want that the Fog appears randomly every 1-2 Min. (thats why the math.random(120,240) thing helps) :smiley:

Ah I gotcha

Just combine both the wait() & math.random() and you should get something like this:

while wait(math.random(120, 240)) do
    game.Lighting.FogEnd = --Number you want to change it to here
    game.Lighting.FogColor = --Color if you want to change it, otherwise it'll default as white

Do keep in mind though that this loop will run infinitely unless if it’s broke by a break statement

1 Like

Yup just found out by myself XD Still thanks ALOT !! I appreciate that

1 Like