Issue with regional fog

This fixed it! The script fully works now. So, how do I add more regions?

I’m really glad it worked! The script goes through the ImportantAssetsService folder to find parts named “FogPartOutside”, so all you would have to do is duplicate your current part and resize/position it.

What if I want to have a different color for different regions? In a theoretical sense, touch one part and the fog turns red, touch a different one it turns blue, a different one and it turns green.

Sure, we can do this with a few more steps.

First we need to add an attribute for each region part. You can add an attribute by scrolling down to the bottom of the properties menu.

image

image

Then add an attribute with the name to “FogColor” (no spaces, CASE sensitive), and set the Type to Color3
image

Then press Save

We now have an attribute and we can edit the color of it.
image

We also need to do this again for the OutdoorAmbient, just incase.

image

Now thankfully we already pass an argument to the Zone parameter of the EnableFog function, so we can easily get the attribute from the zone, by simply modifying the function as so:

local function EnableFog(Zone)
	if Connections[Zone] then -- Ensures that the touch only happens initially  
		Connections[Zone]:Disconnect()
		Connections[Zone] = nil 
	end

	Lighting.FogColor = Zone:GetAttribute("FogColor") -- Sets the fog color to the zone's attribute
	Lighting.FogEnd = 750
	Lighting.Brightness = 0
	Lighting.Ambient = Color3.fromRGB(0, 0, 0)
	Lighting.OutdoorAmbient = Zone:GetAttribute("OutdoorAmbient") -- Sets the outdoor ambient to the zone's attribute
	Lighting:SetMinutesAfterMidnight(300)
end

Boom, now we have zones with different colored fogs!

Here is the file of my test place as well
RegionalFog.rbxl (33.0 KB)
(Note I did not use WaitForChild in my test script because my map is small, so you should still add workspace:WaitForChild("ImportantAssetStorage"):WaitForChild("FogPartOutside") at the beginning of your script)

I have to go now so if you have any more feature ideas, I am sure that you can add them by simply modifying the EnableFog function like I did here, or maybe the DisableFog function as well.

Good luck!

1 Like

Thanks for all the help! I’ll try and set up everything else from here myself, the RBXL you provided should help a bunch here.

1 Like