Fading color with ColorSequence

I have a beam that appears and disappears, by turning white using the mouse button, and then becoming black, but I’m not sure how to gradually fade white to black, specifically with color sequences.

local beam = game.Workspace.Spotlights.Spotlight1.Arm.Head.Lens.AttG.Beam

game.ReplicatedStorage.SpotlightStart.OnServerEvent:Connect(function(player, beam)
	beam.Color = ColorSequence.new(Color3.fromRGB(255,255,255),Color3.fromRGB(255,255,255))
end)

game.ReplicatedStorage.SpotlightStop.OnServerEvent:Connect(function(player, beam)
	beam.Color = ColorSequence.new(Color3.fromRGB(0,0,0),Color3.fromRGB(0,0,0))
end)
1 Like

Here are some other Developer Forums that could help you with your problem at hand.

Hope this helps!

1 Like
local firstColor = ColorSequence.new(Color3.fromRGB(255,255,255),Color3.fromRGB(255,255,255))
local colorSequence = ColorSequence.new(firstColor)

local beam = game.Workspace.Spotlights.Spotlight1.Arm.Head.Lens.AttG.Beam
beam.Color = firstColor

local toTween = Color3.new(255,255,255)
local TweenService = game:GetService("TweenService")
local info = TweenInfo.new(0.3)
local tween = TweenService:Create(beam, info, {Color = toTween})

local runService = game:GetService("RunService")

local function fade()
	local currentColor = beam.Color
	colorSequence = ColorSequence.new(currentColor)
	task.wait()
end

game.ReplicatedStorage.SpotlightStart.OnServerEvent:Connect(function(player, beam)
	beam.Color = ColorSequence.new(Color3.fromRGB(255,255,255),Color3.fromRGB(255,255,255))
end)

game.ReplicatedStorage.SpotlightStop.OnServerEvent:Connect(function(player, beam)
	tween:Play()
	local connection = runService.Heartbeat:Connect(fade())
	tween.Completed:Wait()
	connection:Disconnect()
end)

I used a script I saw in one of the posts, cleaned it up a bit, changed what I needed, and eventually, it stopped working.

I’m not sure what is wrong with it.

Ill get back to you in a bit, Im going to try and re-create the script and get back to you with a proper one.

1 Like

I sadly cannot find any work around to this, I am sorry for wasting your time.

1 Like

That’s alright!

I’ll try and get somewhere with it myself.

I wish you the best of luck, if there is anything else I can help with. Id be more than happy to do so!

Referring to this:

local tween = TweenService:Create(beam, TweenInfo.new(0.3), {Color = lastColor})

That’s what I was stuck on, I don’t think you can tween a beam sadly.

I made it a ColorSequence.

local tween = TweenService:Create(beam, TweenInfo.new(0.3), ColorSequence.new(lastColor))

But it says it still needs a table, even though I made one?

Referring to this, I found an efficient Dev forum post that actually works.

Using Lerp and not tween.

Scratch that post, I used the lerp instead, but I assume I didn’t do it right, cause it doesn’t fade, it just goes to black immediately.

local beam = game.Workspace.Spotlights.Spotlight1.Arm.Head.Lens.AttG.Beam
local colour = beam.Color.Keypoints[1].Value
local Time = 0.3

game.ReplicatedStorage.SpotlightStart.OnServerEvent:Connect(function(player, beam)
	beam.Color = ColorSequence.new(Color3.fromRGB(255,255,255),Color3.fromRGB(255,255,255))
end)

game.ReplicatedStorage.SpotlightStop.OnServerEvent:Connect(function(player, beam)
	for i = 0, 1, wait() / Time do
		beam.Color = ColorSequence.new(colour:lerp(Color3.new(0,0,0), i))
		wait()
	end
end)

Now that I know this semi works, ill work on it again in a bit, ill reply once im finished.

1 Like

The script properly worked for me, thats weird how it didn’t for you.
robloxapp-20230105-0226407.wmv (482.0 KB)
Set the time to 1

My computer (iMac) can’t open that file sadly, haha.

oh lol, let me make it into a mp4 for you really quick.

May I see the script?

I may be able to modify it in terms of my system.

1 Like

I used the same script just change the time to .5 or 1

Not changing the result whether I use .5 or 1

It’s probably something wrong with something outside of the script.

Thats weird it should’ve changed it.
Thats probably something / another script altering it.