Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I make fading/flashing Beam?

I am making spotlights and plan to add flashing beams like spotlight, I have no idea how to script properties of beams at all, thankyou.

1 comment

0

You want the light to turn off and on repeatedly?

2 answers

This site is not a request site. If you make something, we correct it, but not make you the full script. Please watch tutorial videos first, or maybe search it on google, because I won't answer your further requests.

To make a light flash, you have to disable then re-enable it. Put this script inside the part where the SpotLight is:

local time1 = 1 --This is how long you have to wait in seconds for the light to turn off again
local time2 = 1 --This is how long you have to wait in seconds for the light to turn back on
local light = script.Parent.SpotLight --Change this to your needs

while wait(time1) do
	
	light.Enabled = false --Turns light off
	
	wait(time2)
	
	light.Enabled = true --Turns light on
	
end

To make a light fade you have to slowly turn its brightness off or on. You can use the Tween Service (smoother) or a loop (easier) for that:

Loop:

local brightness = 1 --The original brightness value, usually 1
local light = script.Parent.SpotLight

--Fading out:
repeat wait(0.1) --How fast the fading is

	light.Brightness = light.Brightness - 0.01

until light.Brightness == 0

--Fading in:
repeat wait(0.1) --How fast the fading is

	light.Brightness = light.Brightness + 0.01

until light.Brightness == brightness

TweenService:

local brightness = 1
local light = script.Parent.SpotLight
local goal = {}
local TW = game.TweenService
local tweenInfo = TweenInfo.new(1) --How fast the fading is in seconds

--Fading out:
goal.Brightness = 0
local tween = TW:Create(light, tweenInfo, goal)
tween:Play()

--Fading in:
goal.Brightness = brightness
local tween = TW:Create(light, tweenInfo, goal)
tween:Play()

Sorry for my English and let me know if I helped

1 comment

0

Thankyou so much! Helped so much. :)

This discussion is preserved as it was. New answers, comments, and votes are closed.