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

What is wrong with this script?

I been trying to do a light flicker, but it just doesn't work Ex.

function Flicker()
Pointlight.enabled=true
wait(0.8)
Pointlight.enabled=false
wait(.2)
Pointlight.enabled=true
wait(1)
Pointlight.enabled=false
wait(.2)
Pointlight.enabled=true
end

2 answers

✓ Accepted answer

All names and identifiers are case sensitive. That means Enabled and enabled are completely different things

(Certain methods have aliases for both capitalizations, but this is almost never true of properties)

ROBLOX properties are (almost) always Capitalized, so enabled should be Enabled everywhere in this snippet.


You have not defined PointLight as a variable. Probably, it can be defined in a way like this:

local PointLight = script.Parent.PointLight

It's best practice to include variable definitions as far as down as is possible (meaning in this case at the beginning of Flicker.) If you have multiple functions using PointLight you should define the variable above the first (first lexically speaking) function using it.


In addition, the function Flicker is not shown to be called. You can call it with

Flicker()

or call it repeatedly with something like

while true do
	Flicker()
end

or connect to someEvent:

someEvent:connect( Flicker )

1 comment

0

Wow, way to explain O3o

Try to fire the function

function Flicker()
Pointlight.enabled=true
wait(0.8)
Pointlight.enabled=false
wait(.2)
Pointlight.enabled=true
wait(1)
Pointlight.enabled=false
wait(.2)
Pointlight.enabled=true
end

Flicker()

Thumbs up if this helps!

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