I need to tween a beams transparency, but that cant be tweened

heres a line of code that should tween the beam’s transparency:

TweenService:Create(workspace.CoreLasers.CoreLaser1.Cone.Attachment.Beam, TweenInfo.new(0.3), {Transparency = NumberSequence.new(0)}):Play()

the above code is duplicated 8 times, with CoreLaser's number going up by 1 each time until it reaches 8.

I dont know why i cant tween it, it says its not a data type that can be tweened

I also cant link them to a value because i need them all to work individually

proof of issue:

1 Like
  1. You dont need to have 8 different tweens

  2. The transparency property doesnt need a number sequence, thats the whole job of a tween, just do:

TweenService:Create(workspace.CoreLasers.CoreLaser1.Cone.Attachment.Beam, TweenInfo.new(8), {Transparency = 1}):Play()

I’d also recommend giving more arguments to the Tween info as well for better customization

testing right now

char limit

fixes previous error, but gives a new error

I made the tween info 8 seconds cause that’s what I thought you wanted to do, you can change it to a smaller time if necessary.

If it still fails, is your object a model?

heres a diagram of where the beam is

image
ignore ShieldAttachment, that has nothing to do with rn
CoreLasers is a folder parented to workspace.

I apologize my lack of knowledge caught up to me. I just checked the beam api and you have to do the NumberSequence like this:

(from the api)

local numberSequence = NumberSequence.new({
	NumberSequenceKeypoint.new(0, 1), -- transparent
	NumberSequenceKeypoint.new(0.5, 0), -- opaque
	NumberSequenceKeypoint.new(1, 1), -- transparent
	}
)

I am not familiar with beams so this should help you more than it helped me

Just add this to the transparency property and you should be good

how do i insert this?

TweenService:Create(workspace.CoreLasers.CoreLaser1.Cone.Attachment.Beam, TweenInfo.new(8), {Transparency = numberSequence = NumberSequence.new({NumberSequenceKeypoint.new(0, 1), NumberSequenceKeypoint.new(0.5, 0), NumberSequenceKeypoint.new(1, 1), )}):Play()

In your case just make the sequence only transparent
I gtg but someone else can help you further

orange underline under numberSequence

Rather than trying to tween the transparency you could always tween a number value between 0 and 1 (i.e. 0-100%) and then hook Change:Connect() each time the Value changes, and apply those to whatever property you wish:

local number_value = Instance.new("NumberValue");
number_value.Value = 0; -- start at 0 (0%)

-- everytime the Tween changes the number_value's Value it is sent here
-- so we can either store it or apply it to whatever property we wish
number_value.Changed:Connect(function(progress)

	-- apply the progress (inputted to this function) to the property we want to change
	workspace.CoreLasers.CoreLaser1.Cone.Attachment.Beam.Transparency = progress;

end)

local tweenInfo = TweenInfo.new(1);  -- 1 second time length
local tween = game.TweenService:Create(number_value,tweenInfo,{Value=1}); -- finish at 1 (100%)

-- play the tween, wait for it to complete, and destroy it...
tween:Play();
tween.Completed:Wait();
tween:Destroy();

ill see if it works

char limit

got an error

i might make them all connected to a number value and tween it that way

Sorry, I set the number_value = 0 rather than number_value.Value = 0

nah its fine

Im currently trying my way, if it doesnt work ill continue with your way

Okay, but I would encourage this way because it is transferable to any tween you require, you can always use this and store the values into a table and apply them to a NumberSequence using the stored table values. You can also store all tween transitions across multiple timescales and use them to move the camera, move parts, tween GUI transparencies, tween part colours and transparencies. And all using the same piece of code if you Modularise it.

didnt work, ill continue with your way

it said precisely everytime it tried effecting a laser (theres multiple, now you know), it gave me the error "Unable to assign property Transparency. Numbersequence expected, got number", but continued with the script?

Okay you may be better to store the values in a table and build the number sequence after the tween completes. Or you could just apply them like this in the Connect function:

local ns = NumberSequence.new{	NumberSequenceKeypoint.new(progress, progress) };
-- then apply ns to the beam transparencies
workspace.CoreLasers.CoreLaser1.Cone.Attachment.Beam.Transparency = ns;
-- etc

i dont get it, im beginner

:(