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

Transparency Based Brightness?

Asked by 8 years ago

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.

0
use an if then statement. HungryJaffer 1246 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
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.

Ad

Answer this question