How to create localized fog?

Hey everyone, I was wondering how I could make “localized” (as in, it’s only foggy in part of the map) fog.

I already tried using smoke and setting the color to white, but it is very choppy, and if your camera is in a piece of fog, than the fog becomes transparent. So, this solution would not work.

I also can’t use semi transparent parts, because the player is supposed to be able to go into the fog, so the same problem as above would occur. Thanks for the help :slight_smile:

2 Likes

This may help you with what your looking for:

1 Like

Hey, I saw your post and was going to implement it, but I had something come up. Why did you delete the post?

I’ll try this solution though, thank you.

I deleted it because it wasn’t localized, if you still wanted it here you go:

local fog = game.Lighting.Atmosphere

local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)

local goals1 = {
	Density = .75 --Change to how foggy you want it to be
}

local goals2 = {
	Density = .3 
}

local addFogTween = TweenService:Create(fog, tweenInfo, goals1)
local removeFogTween = TweenService:Create(fog, tweenInfo, goals2)



local Part = script.Parent
local tbl = {}  
local debounce = false
local debounce2 = false

game:GetService("RunService").Heartbeat:Connect(function(loop) -- Heartbeat loop
	task.wait() 

	if #tbl == 0 then -- if there isnt anything in table
		if not debounce2 then
			debounce2 = true
			print("Player Outside Part") -- run code
			removeFogTween:Play()
			debounce = false
		end
	end

	if #tbl ~= 0 then -- if there is a part in table
		if not debounce then
			debounce = true
			task.wait()
			print("Player Inside Part") -- run code
			addFogTween:Play()
			debounce2 = false
		end

		table.remove(tbl, 1) -- removes the part from table
	end
	Part.Touched:Connect(function() end) -- creates a touch interest 
	local prt = Part:GetTouchingParts()[1] -- gets the touching parts of the specified part
	table.insert(tbl, prt) -- inserts the part into table
end)

But then I couldn’t figure out on how to localize it, so I resorted to the dev forum, and I was going to use her script but edit it so it works with fog, but I don’t know if that is frowned upon.

Oh, ok. So it seems like the only way to do the localized fog is to change the settings locally?

Well, I’m not much of a scripter, I tried putting it in a local script and that didn’t work (I was going to use a region3, since before I used a touch event)

1 Like