Help with flickering jack o' lantern script

Hey deveopers, I have a pretty simple question. How would I go about making a flickering jack o’ lantern? So far all I’ve done is identify the pointlight which I’d like to flicker since I have no idea how I’d go about making this.

local Pumpkin = script.Parent
local Candle = Pumpkin:WaitForChild("Face"):WaitForChild("PointLight")

local Pumpkin = script.Parent
local Candle = Pumpkin:WaitForChild(“Face”):WaitForChild(“PointLight”)
Candle.Transparency = 1
Wait(. 1)
Candle.Transparency = 0

There’s no Transparency property of point lights

If you don’t want it to loop, use this:

local Pumpkin = script.Parent
local Candle = Pumpkin:WaitForChild("Face"):WaitForChild("PointLight")

Candle.Enabled = false
wait(1) --Replace with the amount of time you want the light to be off.
Candle.Enabled = true

If you want it to loop, use this:

local Pumpkin = script.Parent
local Candle = Pumpkin:WaitForChild("Face"):WaitForChild("PointLight")

while true do
    Candle.Enabled = false
    wait(1) --Replace with the amount of time you want the light to be off.
    Candle.Enabled = true
    wait(10) --How often you want this code to repeat.
end
2 Likes

You should try and add a point light under that candle. then use math.random and whenever it choose a number, you can set the brightness. Use RunService for this m.

If you want a more random flickering pattern, this should be used. You can also use TweenService to make the transition between different brightness values smoother.

1 Like

I’ll try these right now, thanks everybody!

It now works just fine, thanks @Platoon73

local Pumpkin = script.Parent
local Candle = Pumpkin:WaitForChild("Face"):WaitForChild("PointLight")

local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")

local waitTime = math.random(1,10)

local Info = TweenInfo.new(
	2,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	math.huge,
	true,
	0
)

local Tween = TweenService:Create(Candle, Info, {Brightness = 3})
Tween:Play()

while wait(waitTime) do
	Tween:Cancel()
	waitTime = math.random(1,10)
	Candle.Brightness = 0
	wait(1)
	Candle.Brightness = 1
	Tween = TweenService:Create(Candle, Info, {Brightness = 3})
	Tween:Play()
end