Spreading fire system not working

I need help scripting a spreading fire system as a fun little project. However, i keep running into problems.

The fire dosen’t spread. Here is the code:

local spreadtime = 3
local distance = 2

while wait(spreadtime) do
	for i,v in pairs(workspace.Flammables:GetChildren()) do
		local onfire = false
		for r,e in pairs(workspace.Flammables:GetChildren()) do
			if e ~= v then
				local amount = math.random(1,3)
				local x = v.Position.X+distance
				local y = v.Position.Y+distance
				local z = v.Position.Z+distance
				local x2 = v.Position.X-distance
				local y2 = v.Position.Y-distance
				local z2 = v.Position.Z-distance
				local min = v.Position - (distance * v.Size)
				local max = v.Position + (distance * v.Size)
				local fires = 0
				local area = Region3.new(min,max)
				local parts = workspace:FindPartsInRegion3(area,nil,3)
				if not e:FindFirstChild("Fire") then
					if parts[e] then
						local msg = "Fire spread from "..v.Name.." to "..e.Name
						local clone = game.ServerStorage.Fire:Clone()
						clone.Parent = e
						fires = fires + 1
						fires = 0

Any help is appreciated.

So If you could explain whats not working and any errors in the output if any thatd be really great and also any images or videos would also be ideal

There are no errors. It just won’t work. And also, what it does is there is a “Flammables” folder in the workspace, any parts in there would be looped through every 3 seconds and if there is a “Fire” particle in the part it will look for parts that are near it using Region3, then it would spread.

Have you tried debugging with print statements?

Not yet. I’ll try that. Thanks.

1 Like

The error is that it dosen’t detect the part.

Alright so make it detect the part :blush:

Thank you! If you didn’t mention printing i may have not found out why it didn’t work.

1 Like

Dude of course happy to help anytime; debugging with print really helps more than you think