Some of you may know that particle emitters emit less particles for players with lower graphic levels (from settings) than you may have set the rate property to.
In some cases, you may want the particles to be emitted the same amount for everyone, so how do you do that? It’s actually pretty simple, you can have a custom particles system!
Here’s the code:
Code
--- A table (array) to keep the info for each particle
local particleData = {}
--- Assuming you have all the particles you're looking to change in workspace, with the name "CustomParticle"
--- Initializing by adding the particles to the table
for _, obj in pairs(workspace:GetDescendants()) do
--- checking the requirements (classtype and name)
if obj:IsA("ParticleEmitter") and obj.Name == "CustomParticle" then
particleData[#particleData+1] = {
particle = obj,
lastEmit = tick(), -- you can use other time alternatives like os.click() as well
emitTime = 1 / obj.Rate -- somewhat like a cooldown, so that the object emits obj.Rate particles every second
}
obj.Rate = 0
end
end
-- instead of true, you can have the waiting method or a variable in case you'd like to stop all particles at some point
while true do
for i = 1, #particleData do
-- checking if the particle object should emit a particle or not (somewhat like a debounce/cooldown system)
if tick() - particleData[i].lastEmit > particleData[i].emitTime then
particleData[i].lastEmit = tick()
particleData[i].obj:Emit(1)
end
end
wait() --- you can also have RunService's (.event) :Wait() for more accuracy
end
How does it work?
-
Initialize all the particles by placing them inside an array, saving the particle object, the rate and an emission time, which you’ll change later.
-
Change the particle rate to 0, so it does not emit by itself.
-
Have a loop that keeps checking if the particles should or not emit, depending on when it last emitted a particle and how many particles it should emit every second. If you don’t want the loop to yield, just wrap it into a new coroutine thread.
By using a table, you can continue adding particles even after the initialization
EDIT: I’ll finish the module and release it publicly if I see that people want it.
Hopefully you found this useful and even if you may not use this method for this purpose, you can adapt it for all kinds of features
Have a nice day