Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

What is wrong with this script?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Log in to vote
3
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

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 )
0
Wow, way to explain O3o User#5978 25 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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!

Answer this question