The Goal:
A light that smoothly flickers at various brightness levels to create a flickering effect by manipulating both the transparency value of the part and the brightness value of the surfacelight.
Layout:
Current Script:
local TweenService = game:GetService("TweenService")
local Part = script.Parent
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear)
local Tween = TweenService:Create(Part, tweenInfo , {Transparency = 1})
Tween:Play()
Now this script was just a test, but I’m stuck as to what to do now. My idea was to use math.random
to manipulate the brightness within a certain threshold, but there wouldn’t be a way to have that coencide with the transparency.
I barely know any Lua (more of a Node guy) and this is the first time I’m using TweenService for anything really, so forgive me if I look like an idiot.
Why do you want to manipulate the transparency value? Either way you could manipulate the transparency and brightness values at the same time without tween. If you do want to use tween then you could just add brightness to the table with transparency.
{Transparency = 1, Brightness = x}
It would make it look as if the bulb is physically flickering, instead of just the same neon light having a spasm below it. I’ll add it to the table and test it out!
1 Like
You could make a variable named x or something like that and set it as math.random, then apply that to the transparency and brightness values.
local TweenService = game:GetService("TweenService")
local Part = script.Parent
local x = math.random() --you can set the max and minimum if you want to but im not doing that
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear)
local Tween = TweenService:Create(Part, tweenInfo , {Transparency = x, Brightnes = x})
Tween:Play()
Im pretty sure this would work.
2 Likes
try this:
local light = script.Parent -- put light/lamp here
while wait(0.5) do
if math.random(1, 10) == 1 then-- bigger the number less chance or slower flickering.
light.Enabled = true
else
light.Enabled = false
end
end