How would I make a non laggy Building fire

Hey guys, I’m Max. I want to create a Fire simulation on my roblox building to test how well it would go and if it would fall. I currently have a model but it is wayyyy too laggy and drops you down to 9 fps. Just wondering if anyone out there can help!

  1. What do you want to achieve?
    A non laggy fire simulation for my building

  2. What is the issue?
    I have made one but it is wayyyyy too laggy

  3. What solutions have you tried so far?
    I have looked for solutions but to no luck.

Code (inside a part):

script.Parent.Touched:Connect(function(hit)
	if hit:FindFirstChild("Fire") or hit:FindFirstChild("Smoke") or hit:FindFirstChild("Script") or hit.Parent:FindFirstChild("Humanoid") ~= nil then
		return nil
	elseif hit.Locked == true then
		return true
	elseif hit.Name == "Baseplate" then
		return true
	elseif hit:FindFirstChild("Fire") or hit:FindFirstChild("Smoke") == nil then
		local fire = script.Parent.Fire:Clone()
		local smoke = script.Parent.Smoke:Clone()
		fire.Parent = hit
		smoke.Parent = hit
		local scriptc = script:Clone()
		scriptc.Parent = hit
		wait(math.random(10, 60))
		hit.Anchored = false
		hit:BreakJoints()
		wait(math.random(60, 180))
		script.Parent:Destroy()
		end
end)

and here is the full model:
(5) Start Fire - Roblox

Any help would be great!

Definitely the amount of fire objects/smoke objects your instancing causing the issue, consider creating them randomly.

1 Like

I have updated my script for anyone wondering. With the default building in the city template, it works very well and simulates what I wanted it to. I can share it If you guys want

I don’t think the expressions in your if statements work how you think they work :thinking: Doesn’t cause any problems in this case, there’s still only one particle emitter of each type per part, but you might want to read up on that.

Anyway, here’s your issue:

image

Each part will have 100k particles present at a time. That’s waaaaay too many. Confirming that with the microprofiler:

image

Setting it to 100 shows

image

For reference, you only have 16ms to do EVERYTHING per frame if you’re targeting 60fps (which you should, at LEAST).

If you still want the smoke to be “thick”, try making each particle bigger.

So I had it at a 1000 rate? I am surprised I missed that!