How do I make a smooth transitioned flashing light?

Hey there! I’m link and I have a question,
I want to make an flashing light but with smooth transitions so it’s not that bad for the eyes. Is there any way of doing this? If it’s possible, I would like the brick to smoothly transition and the light in it.

The issue is I just can’t find out how, when I try it they start jumping from color to color.

I’ve tried many things such as learning tween service but that was a no go.

If any of you could help I would gladly appreciate it! :heart:

4 Likes

Have you tried using the Run Service?
See more here:

3 Likes

I have actually, but I’m really confused to RunService and TweenService.
It might have to do with that I’m not fully English.

The TweenService is used to Move UI’s, not set the transparency, however the run service is used to change IntValues, so you could use it to Make a smooth Sun Transition, Making a UI background fade, or a flashlight shine.

1 Like

Hm. I get it now. But I still don’t understand run service.

Try reading very carefully through this:

If it doesn’t help, have a look on youtube.

1 Like

I have looked trough it again and just don’t understand. I’ve looked up for it on YouTube but that’s completely different. I can’t find anything like it but a part fading colors, not including the light.

TweenService is actually really simple once you know how. It’s used to make properties of an object transition smoothly.

Let’s say you wanted to make a Part turn invisible. Here’s a sample script:

local TweenService = game:GetService("TweenService") -- Now we have access to the TweenService
local MyPart = workspace:WaitForChild("Name_Of_My_Part") -- This is a reference to the part we want to affect

local MyPartTween = TweenService:Create( -- This is how we create a new animation (tween)
    MyPart, -- The object whose properties we want to change
    TweenInfo.new(
        5 -- We want the animation to be 5 seconds long
    ),
    { -- This is a table which states which properties of MyPart we want to change, and what the new value will be
        Transparency = 1 -- Set the Transparency of MyPart to 1 (invisible).
    }
) -- We have just created an animation for MyPart that will change the Transparency property over the course of 5 seconds
-- If you needed to make another animation, you would create the tween here

while true do -- This is a loop that will play forever
    MyPartTween:Play() -- Play the animation we created
    MyPartTween.Completed:Wait() -- Wait until the animation finishes playing
    -- Restart the loop; play the animation again.
    -- You could now add more animations here that you wish to play in order.
    -- For example, a tween that changes the part transparency back to 0.
    -- The loop will then wait until the part is visible again before it restarts.
end

Hopefully I’ve explained that simply. So to change the colour property, you could create two animations. One with the colour the light is going to change to, and one with the original colour. Play these in order in your loop, as shown above, and you should see it slowly transition between the different colours.

1 Like

Actually, you can use TweenService to set the transparency of a part or even change the value of an IntValue ect. You can use TweenService to change almost any property of an object like its position, size, color and value ect. Here is a little example of how you would use TweenService to smoothly set the transparency of a part.

local TweenService = game:GetService("TweenService") -- Gets TweenService
local Part = workspace.Part

local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear) -- Sets up TweenInfo

local Tween = TweenService:Create(Part, tweenInfo , {Transparency = 1}) -- Creates the tween
Tween:Play() -- Plays the tween

If I am understanding you correctly you want to know how to smoothly change the color of a light? If so the best way to do this is through TweenService.

First off you will need to get TweenService through game:GetService("TweenService") as shown below:

local TweenService = game:GetService("TweenService") -- Gets TweenService
local Light = workspace.Part.PointLight -- The PointLight

Next you will need to set up the TweenInfo. This is all the information about the tween like how long it takes to complete. All you need to do is use TweenInfo.new() and fill in all the relevant arguments:

local tweenInfo = TweenInfo.new(
	10, -- Time the tween takes
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	0, -- Number of times you want it to repeat
	false, -- Do you want it to reverse
	0 -- Delay
)

Next you will have to create the tween and the way you do this is through TweenService:Create(). This has 3 parameters one being the object you want to tween, another one being the TweenInfo and the next a table of all the properties you want to change:

local Tween = TweenService:Create(Light, tweenInfo , {Color = Color3.new(0, 0, 0)}) -- Creates the tween

Now we have all this set up you will notice when you test the script out nothing will happen. This is because you haven’t told the tween to play:

Tween:Play() -- Plays the tween

(Full code below)

local TweenService = game:GetService("TweenService") -- Gets TweenService
local Light = workspace.Part.PointLight

local tweenInfo = TweenInfo.new(
	10, -- Time the tween takes
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	0, -- Number of times you want it to repeat
	false, -- Do you want it to reverse
	0 -- Delay
)

local Tween = TweenService:Create(Light, tweenInfo , {Color = Color3.new(0, 0, 0)}) -- Creates the tween
Tween:Play() -- Plays the tween
2 Likes

I’ll try both of these out! Thanks!

Worth noting that TweenInfo supports the number of times an animation should play and -1 will make it play infinitely, discarding the need for the loop unless you’re knowledgeable of a scenario where this would be okay (I don’t think there are many, if any at all).

1 Like