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

Transparency Based Brightness?

I have a light brick I'm working on that flickers between on and off at random. Either a 0 or 1 transparency for the neon brick to have it glow or not, and a brightness of 0 or 0.7 The current script does not do what I want, obviously, but I cannot figure out how to make the brightness change when the transparency does. Here's what I have now, which obviously turns the light off when the neon is on, which is backwards.

while true do
script.Parent.Transparency = math.random(0,1)
script.Parent.PointLight.Brightness = script.Parent.Transparency
wait(math.random(1,15)*0.1)
end

I'm just wondering if there is a way to make the Brightness 0.7 when the Transparency is 0, and 0 when the Transparency is 1, without explicitly typing all that out.

1 comment

0

use an if then statement.

1 answer

✓ Accepted answer
while true do 
wait()
if script.Parent.Transparency==0 then
script.Parent.PointLight.Brightness=0.7
elseif script.Parent.Transparency==1 then
script.Parent.PointLight.Brightness=0
end
end

Simple if statement, checks if its 0 (Fully 100% visible) , then changes the brightness to 0.7

If its 1 (Is 100% transparent) then it changes the brightness to 0

There may be a simpler way but this is what I would do for my own use.

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