How to make this tool (in a folder in server storage) actually

A. Actually light 50 fires in the server max, which isn’t working… and B. preferably make the fire disappear even when the tool disappears, which is does on death.


B93D02B7-165B-4AED-90F5-588FF6C83F90_4_5005_c

script:
local activeFires = {} – Table to track active fires
local firePart = script.Parent
local canTouch = true
local fireDur = 8
local maxFires = 50

local function onTouch(otherPart)
local hum = otherPart.Parent:FindFirstChild(“Humanoid”)

if hum and canTouch then
	-- Check if the number of active fires is less than the maximum
	if #activeFires < maxFires then
		print("woahhh")
		canTouch = false
		local fire = Instance.new("Fire", otherPart)
		fire.Name = "Fire"

		table.insert(activeFires, fire) -- Add fire to the active fires table

		-- Separate timer for fire removal
		task.delay(fireDur, function()
			if fire and fire.Parent then
				fire:Destroy()
				table.remove(activeFires, table.find(activeFires, fire)) -- Remove fire from active fires table
			end
			canTouch = true
		end)

		-- Damage and tag the player (optional, outside the timer)
		spawn(function()
			while fire and fire.Parent and hum and hum.Health > 0 do
				hum:TakeDamage(1)
				wait(1)
				local CollectionService = game:GetService("CollectionService")
				CollectionService:AddTag(hum, "OnFire")
			end
		end)
	end
end

end

firePart.Touched:Connect(onTouch)