Open Asterune
Light, sound and effects

Light, sound and effects

Configure global lighting, local lights, audio, particles, and explosions.

Lighting properties configure the entire place. Light and effect instances configure effects at specific positions or on parent parts.

Global lighting

Lighting controls time of day, directional lighting, ambient light, shadows, and fog.

Luau
local Lighting = game:GetService("Lighting")
Lighting.ClockTime = 14
Lighting.Brightness = 2
Lighting.Ambient = Color3.fromRGB(70, 70, 80)
Lighting.OutdoorAmbient = Color3.fromRGB(120, 120, 140)

ClockTime uses a range from 0 to 24. Ambient controls ambient lighting on surfaces not directly lit by the sun. OutdoorAmbient controls ambient lighting on surfaces exposed to the sky.

Fog

FogStart and FogEnd specify distances from the camera in studs. Fog begins at FogStart and fully obscures geometry at FogEnd. FogColor specifies the blend color.

Luau
local Lighting = game:GetService("Lighting")
Lighting.FogStart = 60
Lighting.FogEnd = 400
Lighting.FogColor = Color3.fromRGB(140, 150, 170)

Local lights

Parent a light to a part. PointLight emits in all directions. SpotLight emits within a cone. SurfaceLight emits from a face.

The following example requires a part named Lamp in workspace.

Luau
local lamp = workspace:WaitForChild("Lamp")
local light = Instance.new("PointLight")
light.Brightness = 3
light.Range = 24
light.Parent = lamp

Range is the maximum affected distance in studs. Enabling Shadows adds shadow rendering work for the light. Limit shadow-casting local lights when rendering performance is constrained.

The Neon material changes a part's appearance but does not illuminate other parts. Add a light instance to illuminate surrounding geometry.

Sound

A Sound parented to a part is positional. A sound under SoundService or ScreenGui is non-positional.

Luau
local sound = Instance.new("Sound")
sound.Asset = "rbxassetid://9120386436"
sound.Parent = game:GetService("SoundService")
sound:Play()

Play, Pause, Resume, and Stop control playback. PlaybackPosition and Duration are measured in seconds. Duration is 0 until loading completes. PlaybackSpeed changes playback rate and pitch.

For positional audio, RolloffMinDistance is the full-volume radius and RolloffMaxDistance is the inaudible distance, both in studs. RollOffMode selects the attenuation curve.

Destroy temporary sounds after use. Ended reports the end of non-looping playback; looping sounds require separate cleanup.

Particles

ParticleEmitter emits particles from its parent part. This example requires a part named Vent.

Luau
local emitter = Instance.new("ParticleEmitter")
emitter.Enabled = false
emitter.Parent = workspace:WaitForChild("Vent")
emitter:Emit(10)

Rate specifies particles per second during continuous emission. Set Enabled to false to stop continuous emission. Call Emit for a fixed count.

SizeSequence and ColorSequence vary size and color over particle lifetime. SpeedRange selects an initial speed for each particle from a NumberRange. It does not describe a value over the particle lifetime.

Explosions

Configure an Explosion before parenting it into the workspace. Parenting triggers detonation.

Luau
local explosion = Instance.new("Explosion")
explosion.Position = Vector3.new(0, 5, 0)
explosion.BlastRadius = 20
explosion.BlastPressure = 0
explosion.DestroyJointRadiusPercent = 0
explosion.Parent = workspace

BlastRadius is measured in studs. Setting BlastPressure to 0 disables impulses. Joint processing is controlled separately by DestroyJointRadiusPercent. The blast does not directly subtract character health; implement damage through a hit handler. Destroy the explosion instance after use.