How could i make this smoother - ColorSequence

I want to make the change in ColorSequence smooth instead of instant, how would I go about doing this?

I know how to make the part smooth using TweenService, so ignore that, but TweenService isn’t provided for Beams.

				local red = Color3.fromRGB(255, 0, 0)

				local ColorSequenceRed = ColorSequence.new{
					ColorSequenceKeypoint.new(0, red),
					ColorSequenceKeypoint.new(1, red)
				}
				game.Workspace.Spawn.Lights.Beam1.Beam.Color = ColorSequenceRed
				game.Workspace.Spawn.Lights.Beam2.Beam.Color = ColorSequenceRed
				game.Workspace.Spawn.Lights.Beam3.Beam.Color = ColorSequenceRed
				game.Workspace.Spawn.Lights.Beam4.Beam.Color = ColorSequenceRed
				game.Workspace.Spawn.SpawnNeon.Color = Color3.fromRGB(255, 0, 0)
1 Like

Use TweenService on a Color3Value and then make the beam change its color everytime the Color3Value changes.

--Put in a Color3Value
local Value = script.Parent
local Beam = YOUR_PATH_TO_BEAM

local NewColor = Color3.new(255,0,0)

--Set the Value's Value to Beams Color for better performance!

game:GetService("TweenService"):Create(Value,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Value = NewColor}):Play

Value.Changed:Connect(function(val)
    Beam.Color = ColorSequence.new(val)
end)


Got this error, and the ‘play tween’ line is underlined in red.

Ohh i forgot to put () there…

Can you put :Play() instead of :Play there?

i think it will work like that

image
Got another error

		local Value = Color3.fromRGB(255,0,0)
		local Beam = game.Workspace.Spawn.Lights.Beam1.Beam

		local NewColor = Color3.fromRGB(0,255,0)


		game:GetService("TweenService"):Create(Value,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Value = NewColor}):Play()

		Value.Changed:Connect(function(val)
			Beam.Color = ColorSequence.new(val)
		end)

Ohh you need the Value to be a Color3Value object!
image

Does it work with that?

How do i change that?
char limit

Oh okay lemme change the script up a bit

local OldColor = Color3.fromRGB(255,0,0)
local Value = Instance.new("Color3Value",workspace)
Value.Value = OldColor
local Beam = game.Workspace.Spawn.Lights.Beam1.Beam

local NewColor = Color3.fromRGB(0,255,0)


local Tween = game:GetService("TweenService"):Create(Value,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Value = NewColor})

Tween:Play()

Value.Changed:Connect(function(val)
	Beam.Color = ColorSequence.new(val)
end)

--AutoDelete the Value after use (optional)
Tween.Completed:Connect(function()
    Value:Destroy()
end)

try this

Don’t use Instance.new() with the parent argument, it’s terrible for performance.

ok and? it will be deleted a minute later O___O

Just pointed it out, and ye i didn’t see that you destroyed the instance but nonetheless it’s just a PSA.

1 Like

Thanks, it worked just had to edit and change a few things.

1 Like
game:GetService("RunService").Heartbeat:Connect(function()
	local ray = Ray.new(root.Position, root.CFrame.UpVector* -500)
	local part = workspace:FindPartOnRayWithWhitelist(ray, {workspace.Spawn.SpawnNeon})
	if part then
		task.wait()
		if game.Workspace.Spawn.SpawnNeon ~= Color3.fromRGB(0, 255, 0) and Active == false then
			Active = true
			task.wait()
			local OldColor = game.Workspace.Spawn.SpawnNeon.Color
			local Value = game.Workspace.Spawn.SpawnColorVal
			Value.Value = OldColor
			local Beam1 = game.Workspace.Spawn.Lights.Beam1.Beam
			local Beam2 = game.Workspace.Spawn.Lights.Beam2.Beam
			local Beam3 = game.Workspace.Spawn.Lights.Beam3.Beam
			local Beam4 = game.Workspace.Spawn.Lights.Beam4.Beam

			local NewColor = Color3.fromRGB(0,255,0)


			local Tweena = game:GetService("TweenService"):Create(Value,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Value = NewColor})
			local Tweenb = game:GetService("TweenService"):Create(Value,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Value = NewColor})
			local Tweenc = game:GetService("TweenService"):Create(Value,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Value = NewColor})
			local Tweend = game:GetService("TweenService"):Create(Value,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0),{Value = NewColor})
			Tweena:Play()
			Tweenb:Play()
			Tweenc:Play()
			Tweend:Play()

			Value.Changed:Connect(function(val)
				task.wait()
				Beam1.Color = ColorSequence.new(val)
				Beam2.Color = ColorSequence.new(val)
				Beam3.Color = ColorSequence.new(val)
				Beam4.Color = ColorSequence.new(val)
			end)

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

			local ChangeColor =
				{
					Color = Color3.fromRGB(100, 255, 50),
				}

			local Tween1 = TweenService:Create(game.Workspace.Spawn:WaitForChild("SpawnNeon"), Info, ChangeColor)	

			Tween1:Play()
			task.wait()
			Active = false
		else
		end

This part of the script is causing a lot of lag, do you know why?
I just tried in-game and whenever this part of the code is running, ping increases and fps drops crucially.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.