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

How to tween colors in beams?

Asked by 5 years ago

I'm trying to get a beam to tween to a different color when I click a button on my gui! I've tried multiple things with the color sequences and the script below is the one that seems to have the least errors, but it still doesn't work.

Script:


gui = script.Parent ts = game:GetService("TweenService") info = TweenInfo.new( 0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0 ) local goal = { ColorSequence.new(Color3.new(color.r, color.g, color.b) = gui.Color.Value } gui.MouseButton1Down:connect(function() ts:Create(game.workspace.Light.Beam,info,goal):Play() end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

The input of a beam color is a ColorSequence datavalue instead of a Color3 datavalue.

You can either input two Color3 values, but this means it will only change from one color to the other (white to black in this case.).

ColorSequence.new(Color3.new(1,1,1),Color3.new(0,0,0))

Or with a table input of ColorSequenceKeypoint datavalues:

ColorSequence.new(
{
ColorSequenceKeypoint.new(0,Color3.new(1,0,0)),
ColorSequenceKeypoint.new(.5,Color3.new(0,1,0)),
ColorSequenceKeypoint.new(1,Color3.new(0,0,1))
}
)

The first input of a ColorSequenceKeypoint is the time (max value of time is 1), the second is the color (inputted as a Color3 value. So in the code shown above the beam would first be red then turn green and then blue, a little nice rainbow effect.

Ad

Answer this question