Is there any way to tween Beam Transparency / NumberSequences?

I have a slight issue where I am trying to create a spotlight system for a dance club. I need the spotlights to be able to dim and change intensity. I am using beams to replicate the light beams from the spotlights, but the transparency property on beams is a NumberSequence. NumberSequences are not tweenable, as far as I know.

Does anyone know of a workaround for this?

A sort of hacky workaround would be to tween some variables and just use those to update your NumberSequences in a separate thread

A variadic function with a coroutine for updating the NumberSequence would probably work well enough for this use case

If you’re simply trying to reduce the overall transparency, you could do this:

local function tweenTransparency(object, fromValue, toValue, tweenInfo)
	local numberValue = Instance.new("NumberValue")
	numberValue.Value = fromValue
	
	numberValue.Changed:Connect(function(value)
		object.Transparency = NumberSequence.new({
			NumberSequenceKeypoint.new(0, value),
			NumberSequenceKeypoint.new(1, value)
		})
	end)
	
	local tween = tweenService:Create(numberValue, tweenInfo, { Value = toValue })
	tween.Completed:Once(function()
		numberValue:Destroy()
	end)
	
	tween:Play()
end

tweenTransparency(beamObject, 0, 1, TweenInfo.new(5)) -- Example to tween transparency from 0 to 1 over 5 seconds.
1 Like