How to create a fog with a color when you enter a area

How could i create fog similar to those of [IMPROVISED] Feedback on my Jungle so far?

However it only appears when you enter the jungle.
Fogend will not work since that will be globally, should i use a local script to change the fogend when a player enters the area?

Thank you!

You could use Region3 to detect whenever the player enters/leaves the area, then you add/remove the fog depending of the situation.

Locally created fog with spatial API queries would work well.

Thank you! Both of these work will probably work well together.

Would particle emitter work? The jungles floor is a part so could i put a particle emitter in it and emit green smoke (fog)

Sure but particle emitters do not emit particles over long distances.

If you don’t need to check layered regions (e.g. areas in multiple floors), my personal suggestion here is to downcast (raycast downward) every frame and check if the raycast hits an area part. If it does and the current area marker hasn’t been updated then you can do so and apply effects.

Rough pseudocode:

local lastArea = "N/A"

Heartbeat:Connect
    raycast(RootPartPosition, Vector3.new(0, -10, 0), WhitelistAreaBricks)
    if raycast_hit(area_part)
        local area = area_part:GetAttribute("Area")
        if area ~= lastArea then
            lastArea = area
            applyEffect_showAreaOnGui

If you have 3D regions to check over then spatial queries would be more appropriate but it tends to also be more expensive to cast so I wouldn’t recommend it unless you have deeply complex spatial locations to check over. Raycasts are highly inexpensive when short so they should be your go-to.

1 Like