Lights Out
Lesson 1 of 25 in Coddy's Roblox Game: Escape the Dark course.
In this course you build an escape game: dark rooms that open one after another, a flashlight, keys and a vault, and a monster that hunts you while you hide, run and look for the way out. It is scary because it is dark, not because of anything gory.
The Lighting service sets the scene. ClockTime is the hour (0 is midnight, so no sun), Ambient is the light in places the sky does not reach, such as indoors, OutdoorAmbient the light outdoors, and fog hides what is far away:
Lighting.ClockTime = 0
Lighting.FogColor = Color3.new(0, 0, 0)
Lighting.FogEnd = 120 -- you see 120 studs, then blackThe numbers come from ReplicatedStorage.Settings, so the darkness can be tuned in one place.
Challenge
EasyMake the game night.
- Set
Lighting.ClockTimetoSettings.ClockTime. - Set
Lighting.AmbientandLighting.OutdoorAmbienttoSettings.Ambient. - Set
Lighting.FogColortoColor3.new(0, 0, 0)andLighting.FogEndtoSettings.FogEnd. - Print
Lights out.
Press Play: the lobby goes dark and black fog closes in. Then Check.
Try it yourself
-- DarkServer: the Script that runs the game, on the server.
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Lighting = game:GetService("Lighting")
local Settings = require(game.ReplicatedStorage.Settings)
-- Make it night: set Lighting's ClockTime, Ambient, OutdoorAmbient,
-- FogColor (black) and FogEnd from Settings. Then print "Lights out".
All lessons in Roblox Game: Escape the Dark
Practice on your own: Roblox playground