How to tween color on beam

Trying to tween my green beam to red but I get this error, how would I fix this?

			local ColorChange = TweenInfo.new(
					0.25, -- Time
					Enum.EasingStyle.Sine, -- Easing Style
					Enum.EasingDirection.Out, -- Easing Direction
					0, -- Repeats
					false, -- Reverse
					0 -- Delay
				)

				local Red =
					{
						Color = ColorSequence.new(Color3.fromRGB(255, 0, 0),Color3.fromRGB(255,0,0))
					}

				local Change1 = TweenService:Create(game.Workspace.Spawn.Lights.Beam1:WaitForChild("Beam"), ColorChange, Red)	
				local Change2 = TweenService:Create(game.Workspace.Spawn.Lights.Beam2:WaitForChild("Beam"), ColorChange, Red)	
				local Change3 = TweenService:Create(game.Workspace.Spawn.Lights.Beam3:WaitForChild("Beam"), ColorChange, Red)	
				local Change4 = TweenService:Create(game.Workspace.Spawn.Lights.Beam4:WaitForChild("Beam"), ColorChange, Red)	
				Change1:Play()
				Change2:Play()
				Change3:Play()
				Change4:Play()

1 Like

Color sequences cannot be tweened

Is there an alternate way I can change the color of my beams smoothly then? Other games do this.

You could do a

— set values to starting color
Local r = 255
Local g = 0
Local b =0
Repeat
Beam.color = r, g, b
R -= 1 —change values as desired
G += 1
B = 0
Until beam.color == 0, 255, 0 —set as ending color

And then add task.wait to make it slower

You would have to Manually Lerp the Color towards the Target before Applying the Color3, unless you are applying Keypoints onto the ColorSequence

local InterpolatedColor = Start:Lerp(Target, alpha)

Beam.Color = ColorSequence.new(InterpolatedColor)
2 Likes

Honestly, “Tweening” color sequences or number sequences can be a pain, since you’ll need your own tweening process for that, luckily Roblox does provide TweenService:GetValue(alpha, easing_style, easing_direction) to help with that process.

Personally I compile the sequences into a easily readable and manipulatable table, which can also be used to set a sequence. Then run each value through a lerp process, either manual or using roblox’s GetValue from tween service. The only caveat to tweening sequences is you have to have the same amount of timesteps for it to look good without snapping.

I see a lot of people mimicing tween’s using basevalues like Instance.new("NumberValue") then tween the number value from 0 → 1 while having the base value hooked up to a .Changed:Connect() event. It works quite well tbf.

-- // turns color sequence into an editable keypoints
function module:GetKeypoints(colorSequence)
	local keypoints = {}

	for _, keypoint : ColorSequenceKeypoint in pairs(colorSequence.Keypoints) do
		table.insert(keypoints, {Time = keypoint.Time, Value = keypoint.Value})
	end

	return keypoints
end

A workaround I found is to tween a color3 value and set the beam’s color using that.