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

How to make a flickering light?

i tried everything. I am making a horror map and i need a flickering light.

1 comment

0

Sorry for the Moderation Message you may have received. I accidentally locked your question as Not Constructive not realising the fact you had already posted an attempt at the script. I have reset the moderation on your question. In the future, please use the Edit feature under your name in the post to edit questions and answers.

5 answers

Here is an esier way then FuriousGamer's answer

Also i haven't tested it so idk if It will work

local Light = script.Parent -- Or wherever your point light is

while wait(.01) do
	wait(math.random(.1, 1)) -- if this script dosen't work try changing the math.randoms to		math.random(0,1)
		light.Enabled = false
	wait(math.random(.1, 1))
		light.Enabled = true
end

**PS:**Next time don't ask us to make a script for you, Post your version of the script and we'll help you from there ^^

2 comments

0

Your Instance Light has the L capitalized while it doesn't under in the script.

0

FormFactor is deprecated. You should no longer use this property

create this script

while wait() do

--By FuriousGamer_129 --Made in //~~

--This is a script for an infinite flickering light effect. --You need to have a part called "Light" and make sure that it has a "Pointlight" inside it. --Put this script in the Workspace

light = game.Workspace.Light.PointLight

light.Enabled = true
wait(.2)

light.Enabled = false
wait(.1)

light.Enabled = true
wait(.4)

light.Enabled = false
wait(.2)

light.Enabled = true
wait(.3)

light.Enabled = false
wait(.6)

end

--You can change the wait times.

Here try this one.

local light = script.Parent -- The location of the light
while wait(math.random(1,5)) do
	light.PointLight.Enabled = true -- Change "PointLight to your lighttype"
	wait(.1)
	light.PointLight.Enabled = false -- Change "PointLight to your lighttype"
end

Here is the simplest way of doing this. It even has decimal waits!

math.randomseed(tick()) --To make random actually random
light = workspace.Part.Pointlight --change this value into your light object


while wait(math.random(1,1000)/1000) --waits a random number between 0.001 and 1
	light.Enabled = not light.Enabled --Changes the light into the state that it is not currently in (true -> false, false -> true)
end

This one is WAY more efficient and shorter than all the other scripts. It is also much more random.

while wait(math.randomseed(0,1) do
	light.PointLight.Enabled = not light.PointLight.Enabled
end

If the not light.PointLight.Enabled doesnt work then do this, if it still doesnt work then just use math.random instead of math.randomseed:


while wait(math.randomseed(0,1) do
	if light.PointLight.Enabled == true then
		light.PointLight.Enabled = false
	else 
		light.PointLight.Enabled = true
	end
end

Hope this helped, feel free to press the Accept Answer Button!

2 comments

1

math.randomseed sets a seed for scripts to base their math.random function off on. https://scriptinghelpers.org/questions/17929/

0

Oh, sorry about that. Just use math.random(0,1) then

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