The script I’m currently using to attempt to change the color of a beam doesn’t seem to work.
I even used print statements, and they don’t show up in the output view.
It is meant to turn the beam fully white when I click, and it should fade to black when I release the mouse. (MouseButton1)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local spotlightModel = workspace.Spotlights
local spotlights = {
spotlightModel.Spotlight1.Arm.Head.Lens.AttG.Beam,
spotlightModel.Spotlight2.Arm2.Head2.Lens.AttG.Beam,
}
local startColor = ColorSequence.new(Color3.fromRGB(255,255,255),Color3.fromRGB(255,255,255))
local endColor = ColorSequence.new(Color3.fromRGB(0,0,0),Color3.fromRGB(0,0,0))
local fadeTime = 0.3
local lightAnimations = {}
for _, Beam in spotlights do
lightAnimations[Beam] = TweenService:Create(Beam, TweenInfo.new(fadeTime),{Color = endColor})
end
function fade(Beam)
local tween = lightAnimations[Beam]
if lightAnimations[Beam] then
if tween.PlaybackState == Enum.PlaybackState.Playing then
tween:Cancel()
end
tween:Play()
end
end
game.ReplicatedStorage.SpotlightStart.OnServerEvent:Connect(function(player, Beam)
local tween = lightAnimations[Beam]
if lightAnimations[Beam] then
if tween.PlaybackState == Enum.PlaybackState.Playing then
tween:Cancel()
end
end
Beam.Color = startColor
print("on")
end)
game.ReplicatedStorage.SpotlightStop.OnServerEvent:Connect(function(player, Beam)
fade(Beam)
print("off")
end)