Cannot Tween transparency due to type mismatch

So I wish to change a beam’s transparency using Tween/TweenService, however I keep getting the following error:

TweenService:Create property named ‘Transparency’ cannot be tweened due to type mismatch (property is a ‘NumberSequence’, but given type is ‘double’)

Which I can only assume is because the goal target is a double, which from what I can tell should be a single value/number.

local blo = script.Parent.Blade.Start:WaitForChild("Beam")
local start = script.Parent.Blade.Start
local eend = script.Parent.EndPart:WaitForChild("End")

local TweenService = game:GetService("TweenService")

local blostarti = TweenInfo.new(0.1)
local blostopi = TweenInfo.new(1)

local goal1 = {}
goal1.Transparency = 0
local goal2 = {}
goal2.Transparency = 1

local blostart = TweenService:Create(blo, blostarti, goal1)
local blostop = TweenService:Create(blo, blostopi, goal2)
--Everything below this line is pretty much working as intended,  as I found out in testing the code with brightness instead of transparency
while true do
	wait(5)
	if blo.Transparency == 0 then
		blostop:Play()
	else
		blostart:Play()
	end
end

Here is the explorer view, should it prove to be any help:
image

Do note that I have tried replacing Transparency with Brightness and it worked as intended.
I have put the beam’s initial Transparency as a single number (0), but it’s still the same message.
I have tried searching scouring the internet for this problem but apparently my Googling skills aren’t on-par with this issue.

2 Likes

A beams transparency is a NumberSequence, not a plain old number. Unfortunately tweening a number sequence is a bit more uhh… awkward, since the value can’t be directly tweened.

A workaround I’d try is to create a number value, connect a .Changed event then just tween that value.

local connection
connection = numberValue.Changed:Connect(function(n) --> remember to pre-define 'numberValue' or create a new one
    beam.Transparency = NumberSequence.new(n) --> also remember to pre-define 'beam'
end)

then wait for the tween to end using tween.Completed:Wait(), then disconnect that connection and destroy that value.

6 Likes