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 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.
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)