How To animate Number Sequence Keypoints

Hello Evening from ma7adi805, anyways I am trying to animate numbersequence since i cant use tween

and this is what i came up with

spawn(function()
		local BeamTrans = 0
		if BeamTrans>0.5 then
			repeat 
				print(BeamTrans, Beam.Transparency.Keypoints[1].Value)
				Beam.Transparency = NumberSequence.new(BeamTrans+0.05,1)
				BeamTrans+=0.05
				wait(0.15)
			until BeamTrans<=0.5
		else
			repeat 
				Beam.Transparency = NumberSequence.new(BeamTrans-0.05,1)
				BeamTrans-=0.1
				wait(0.15)
			until BeamTrans>=0.5
		end
	end)

when i use this script it instantly makes the transparency in the value it is needed without animation showing and i want it show because i need the fade in/out effect

Please help, thank you

That’s because the code changes it immediately to the final form and doesn’t do anything in between. I made some changes to your code. Try it:

spawn(function()
    local BeamTrans = 0
    local increment = 0.05
    local waitTime = 0.15
    
    while true do
        if BeamTrans < 0.5 then
            -- Fade in
            repeat
                BeamTrans = BeamTrans + increment
                Beam.Transparency = NumberSequence.new({
                    NumberSequenceKeypoint.new(0, BeamTrans),
                    NumberSequenceKeypoint.new(1, 1)
                })
                print(BeamTrans, Beam.Transparency.Keypoints[1].Value)
                wait(waitTime)
            until BeamTrans >= 0.5
        else
            -- Fade out
            repeat
                BeamTrans = BeamTrans - increment
                Beam.Transparency = NumberSequence.new({
                    NumberSequenceKeypoint.new(0, BeamTrans),
                    NumberSequenceKeypoint.new(1, 1)
                })
                print(BeamTrans, Beam.Transparency.Keypoints[1].Value)
                wait(waitTime)
            until BeamTrans <= 0
        end
    end
end)