Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do I make spreadable fire?

here is my code so far, the torch works but it won't spread to my other part. I want the fire to spread to certain parts though.

local burnable = script.Parent
local burnable2 = game.Workspace.burnable2


burnable2.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("torch") then
		burnable2.Fire.Enabled = true
		wait(20)
		burnable2:Destroy()
	elseif hit.Parent:FindFirstChild("burnable") and burnable.Fire.Enabled == true then
		burnable2.Fire.Enabled = true
		wait(8)
		burnable2:Destroy()
		print("burnable touched me")
	end
end)

1 answer

My way i would do it

local Workspace = game:GetService("Workspace")

local firePart = script.Parent

local maxDistance = 10
local minSpreadTime = 2
local radiusIncreaseTime = 0.5

local counter = 1

--[[
-- You could use a bindableEvent to stop the fire
local StopFire = game.ServerStorage.StopFire

StopFire.Event:Connect(function()
	local Fire = firePart:FindFirstChild("Fire")
	if Fire then
		Fire:Destroy()
	end
	script:Destroy()
end)
]]

wait(minSpreadTime)

while wait(radiusIncreaseTime) do
	if counter < maxDistance then
		counter += 1
	end
	for _, Part in pairs(workspace:GetDescendants()) do
		if Part ~= firePart and not Part:FindFirstChild("Fire") and Part:IsA("BasePart") and (Part.Position -  firePart.Position).Magnitude < counter then
			--if Part:FindFirstChild("burnable") then
				local Clone = Instance.new("Fire", Part)
				Clone.Size = Part.Size.X + Part.Size.Y + Part.Size.Z
				
				local FireScript = script:Clone()
				FireScript.Parent = Part
			--end
		end
	end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.