Attempt to perform arithmetic (sub) on NumberRange and number

well, i’m making a torch system, and I encounter this error, i did some research and I tried to use tostring, but i dont know how to use it for my system. Someone please help?

script:

script.Parent.PointLight.Range -= 1
script.Parent.ParticleEmitter.Rate -= 5
script.Parent.ParticleEmitter.Speed -= 1

That just means that you need to use a NumberRange when changing speed. Something like this

emitter.Speed = NumberRange.new(emitter.Speed.Min - 1, emitter.Speed.Max - 1)
2 Likes

try this:


-- Variables

local PointLight_Range = tonumber(script.Parent.PointLight.Range)
local ParticleEmitter_Rate = tonumber(script.Parent.ParticleEmitter.Rate)

------- System

wait(2) -- delay

script.Parent.PointLight.Range = (PointLight_Range-1)
script.Parent.ParticleEmitter.Rate = (ParticleEmitter_Rate-1)

I do not know how to solve the part of ParticleEmitter.Speed

Sorry. :pensive:

1 Like

You can put my system together with @DarkDanny04 and it worked.

-- Variables

local PointLight_Range = tonumber(script.Parent.PointLight.Range)
local ParticleEmitter_Rate = tonumber(script.Parent.ParticleEmitter.Rate)

------- System

wait(2) -- delay

script.Parent.PointLight.Range = (PointLight_Range-1)
script.Parent.ParticleEmitter.Rate = (ParticleEmitter_Rate-1)
script.Parent.ParticleEmitter.Speed = NumberRange.new(script.Parent.ParticleEmitter.Speed.Min - 1, script.Parent.ParticleEmitter.Speed.Max - 1)
1 Like