Cannot subtract from NumberSequence

I’m using for loops for this.
I’m currently trying to make a more efficient way of fading transparency without TweenService.

Unfortunately I stumbed across this error:

This is the problematic line:


This error only pops up when I add - behind =

Here’s the for loop part of the script that is not functioning, everything else is fine.
image

Any way I can fix this…?

I suggest looking at the evalNS function:

https://developer.roblox.com/en-us/api-reference/datatype/NumberSequence

for i = 1, 0, -0.25 do
    Lens.Transparency = i
    light.Transparency = NumberSequence.new(i, 1)
    spotLight.Brightness += 2.5
    task.wait()
end

or

local currentValue = light.Transparency.Keypoints[1].Value
light.Transparency = NumberSequence.new(currentValue - 0.25, 1)

also make sure to benchmark because tweenservice is already efficient so you might not be saving any performance by doing this

Running TweenService on server is not a good thing to do as far as I know…

Let me try the code first although.

Running the tween service on the server side

Or

Setting a instance property many times on the server side

Have the same negative effect of having to send the instant properties over the network to all the clients multiple times

Running TweenService on the server is all fine. :slight_smile:

That is not to say, that you should overdo them.

Hi!

I would suggest that you keep doing tweens. But if you insist on sticking to your work-around method, then I would suggest this for the beam:

Fixture.Head.Beam.Light.Transparency = NumberSecuence.new((.25*5)-(.25*i),1) -- I tried to adapt the method to your for-loop, which right now loops through 5 times.