How do I make the lights fader use tween service?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Trying to make floor lasers use tween service

  2. What is the issue? The lights don’t fade smoothly.

  3. What solutions have you tried so far?

– Code doesn’t use tweenservice
local pointlight = script.Parent

local open = game.ServerStorage.Robberys.Configuration[“Bank IsOpen”].Value
local AlarmIsActive = workspace.Bank.Vault.Vault.Configurations.AlarmIsActive.Value

function FadeOn()
for i = 0,10,0.5 do
pointlight.Brightness = i
wait(0.01)
end
end

function FadeOff()
for i = 10,0,-0.5 do
pointlight.Brightness = i
wait(0.01)
end
end

while wait(0.01) do
FadeOn()

repeat wait() until pointlight.Brightness == 10

FadeOff(0.01)

repeat wait() until pointlight.Brightness == 0

end

3 Likes

Try changing the i decrease to something like .1 instead of .5 or maybe even lower, you can’t tween a transparency number

But how do I make it fade on for in 0.5 and off in 0.5?

It’s pretty simple!
Just using tweenservice, as it can tween any numbers.

game:GetService('TweenService'):Create(pointlight, TweenInfo.new(1 --[[Time!]], {Brightness = 10})):Play()
1 Like

Ok thanks! I fought it wasn’t possible,

I got a error how do I fix it?

Hi, it’s your script with tween service. (In full)

local TweenService = game:GetService("TweenService")--Get tween service
local pointlight = script.Parent

--Set tween duration
local tweenInfo = TweenInfo.new(1)

--Set goal for fist tween with a dictionary
local goal = {}
goal.Brightness  = 10

--Create first tween
local tweenFadeOn = TweenService:Create(pointlight, tweenInfo, goal)

--Set goal for second tween with a dictionary
goal.Brightness  = 0

----Create second tween
local tweenFadeOff = TweenService:Create(pointlight, tweenInfo, goal)



while wait() do
    tweenFadeOn:Play() --Play first tween
    tweenFadeOn.Completed:Wait() --Wait for play end

    tweenFadeOff:Play() --Play second tween
    tweenFadeOff.Completed:Wait() --Wait for play end
end
3 Likes

Thanks for the help! I will try to make it work.