I am trying to manipulate properties of a particle emitter with a script, the particleemitter is a child of a BasePart and an integer is being assigned to .Rate, however I get the error attempt to index number to Rate, and I dont know why because Rate is seemingly a number unlike the other properties, right?
Is this the wrong method of altering particleemitter properties, and if so how can I correctly manipulate them? And perhaps any advice or tips on manipulating the other properties would be useful too!
its just a local variable that refers to the directory of the particleemitter instance:
placeholdervariable = 5
(not the exact code, but more or less identical)
just like any other float / integer value, single equals to assign a compatible data value to overwrite existing value
I’m just confused as to why the error is being caused.
It is a server script mind, but it defo doesnt seem like the error is due to being unable to find or change the value, the error implies that its trying to assign an incorrect data type to Rate
the script is a child of a model that contains the particleemitter
the particleemitter.Rate is defined as the local variable E1rate, and is set a float value, I dont see why the error is saying that number is being set to Rate, as if Rate is a data type itself.
Base1 is the primary part of a moving vehicle model. The script increases the rate based on the speed.
why send images … can i just copy paste it into my editor pls.
A part on the workspace with a Script in it and a ParticleEmitter:
wait(5)
local base1 = script.Parent
local effect = script.Parent.ParticleEmitter
while true do wait()
local Elrate = 5 + base1.Velocity.Magnitude / 1.2
effect.Rate = Elrate
end
This seems to work and will change the value. However the part (i know) isn’t moving in my test. I was hoping the math would set off your error … now I’m thinking the way you’re linking Elrate to Rate is the problem.
I dont see how it would be the problem though, variables work just fine for directories and the error seems to imply that a number value is being set to Rate when it isnt
And when you click on the error in the output it should take you to where that call errored. Something is calling Rate wrong … you need to find it. Maybe use a tonumber() Also can’t see why Rate would cry over a number being sent to it. It loves numbers of any type. Are you sure you’re setting the Rate you’re thinking.
well when assigning the Directories to the variables the autofill showed that they were correct, so I’m not sure why it would have an issue over it. Gonna try moving some code around to see if I can find a fix
I tried using .Rate with a local variable rather than having a variable using .Rate and it is working, so I fixed the problem but still unsure why that didnt work
It works like that because when you do it your original way, the script thinks you are re-defining the variable and not settting the rate, to avoid this I NEVER store property values and int.Value UNLESS it’s to save their og value before you change it