Skip to main content

Lighting

This is a MapLib Feature. It can be accessed by MapLib:GetFeature("Lighting").

Functions

SetLighting

since 0.11
</>
Lighting:SetLighting(
properties{[string]any},
postEffects{[string]{[string]any}}
) → ()

This function can to be used to change the lighting of a map mid round. We discourage usage of changing lighting with game.Lighting[Property] = value cause it doesnt replicate for spectators.

Example:

-- Changes the fog to 100 and the fog color to white
local LightingFeature = MapLib:GetFeature("Lighting")

LightingFeature:SetLighting({
	FogEnd = 100,
	FogColor = Color3.fromRGB(255, 255, 255)
})
info

This function also supports lighting effects to be updated and they will be replicated to specators.

-- Changes the fog to 100 and the fog color to white and makes everything monochrome.
local LightingFeature = MapLib:GetFeature("Lighting")

LightingFeature:SetLighting({
	FogEnd = 100,
	FogColor = Color3.fromRGB(255, 255, 255)
}, {
	ColorCorrection = {
		Saturation = -1,
	},
})
caution

For the game to be able to edit post effects they have to be correctly placed inside the lighting folder inside settings. If they are created in a script the game will not see these and refuse to update the lighting properties.

tip

Since atmosphere instances don't have any enabled or disabled property we can get around that by parenting the instance to ReplicatedStorage and then we can parent it back to lighting when we need it.

local LightingFeature = MapLib:GetFeature("Lighting")

--Disables the atmosphere effect
LightingFeature:SetLighting({}, {
	Atmosphere = {
		Parent = game.ReplicateStorage,
	},
})

task.wait(5)
--Enables the atmosphere effect
LightingFeature:SetLighting({}, {
	Atmosphere = {
		Parent = game.Lighting,
	},
})
Show raw api
{
    "functions": [
        {
            "name": "SetLighting",
            "desc": "This function can to be used to change the lighting of a map mid round. We discourage usage of changing lighting\nwith `game.Lighting[Property] = value` cause it doesnt replicate for spectators.\n\n**Example:**\n```lua\n-- Changes the fog to 100 and the fog color to white\nlocal LightingFeature = MapLib:GetFeature(\"Lighting\")\n\nLightingFeature:SetLighting({\n\tFogEnd = 100,\n\tFogColor = Color3.fromRGB(255, 255, 255)\n})\n```\n\n:::info\n This function also supports lighting effects to be updated and they will be replicated to specators.\n```lua\n-- Changes the fog to 100 and the fog color to white and makes everything monochrome.\nlocal LightingFeature = MapLib:GetFeature(\"Lighting\")\n\nLightingFeature:SetLighting({\n\tFogEnd = 100,\n\tFogColor = Color3.fromRGB(255, 255, 255)\n}, {\n\tColorCorrection = {\n\t\tSaturation = -1,\n\t},\n})\n```\n\n:::\n:::caution\nFor the game to be able to edit post effects they have to be correctly placed inside the lighting folder inside settings.\nIf they are created in a script the game will not see these and refuse to update the lighting properties.\n:::\n\n:::tip\nSince atmosphere instances don't have any enabled or disabled property we can get around that by parenting the instance to ReplicatedStorage\nand then we can parent it back to lighting when we need it.\n\n```lua\nlocal LightingFeature = MapLib:GetFeature(\"Lighting\")\n\n--Disables the atmosphere effect\nLightingFeature:SetLighting({}, {\n\tAtmosphere = {\n\t\tParent = game.ReplicateStorage,\n\t},\n})\n\ntask.wait(5)\n--Enables the atmosphere effect\nLightingFeature:SetLighting({}, {\n\tAtmosphere = {\n\t\tParent = game.Lighting,\n\t},\n})\n```\n:::",
            "params": [
                {
                    "name": "properties",
                    "desc": "",
                    "lua_type": "{ [string]: any }"
                },
                {
                    "name": "postEffects",
                    "desc": "",
                    "lua_type": "{ [string]: { [string]: any } }"
                }
            ],
            "returns": [],
            "function_type": "method",
            "since": "0.11",
            "source": {
                "line": 101,
                "path": "src/Features/Lighting.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Lighting",
    "desc": "This is a MapLib Feature. It can be accessed by `MapLib:GetFeature(\"Lighting\")`.",
    "source": {
        "line": 21,
        "path": "src/Features/Lighting.lua"
    }
}