Menu
CoddyTech

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 black

The numbers come from ReplicatedStorage.Settings, so the darkness can be tuned in one place.

challenge icon

Challenge

Easy

Make the game night.

  1. Set Lighting.ClockTime to Settings.ClockTime.
  2. Set Lighting.Ambient and Lighting.OutdoorAmbient to Settings.Ambient.
  3. Set Lighting.FogColor to Color3.new(0, 0, 0) and Lighting.FogEnd to Settings.FogEnd.
  4. 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