Fire not mass spreading

Fire script: (ignore comments)

local StartingPart = workspace:WaitForChild("FirePart") --replace part with you parts name

_G.parts = {StartingPart} --Removed StartingPart from the table because it gets added automatically
_G.ex_parts = {}

_G.TurnPartIntoFire = function(v: BasePart,change) --"v" is simply the name of the item passed in the function ": BasePart" is just saying that the item passed is supposed to be a BasePart
	table.insert(_G.parts,v)
	local mat = v.Material
	v.Material = Enum.Material.Neon
	v.Color = Color3.fromRGB(math.random(210,220), math.random(110,120), math.random(40,60))
	local fire = Instance.new("Fire",v)
	fire.Size = (v.Size.X+v.Size.Y+v.Size.Z)/3
	wait(2)
	FirePartTouched(v)

	wait(2)
	v.Color = Color3.fromRGB(math.random(140,160), math.random(80,100), 0)
	if change or true then
		v.Anchored = false --This is not really needed since the spread function checks if the part is unanchored or not
		v:BreakJoints()
	end
	
	wait(1)
	v.BrickColor = BrickColor.new("Black")
	v.Material = mat
	table.insert(_G.ex_parts,v)
	table.remove(_G.parts,table.find(_G.parts,v)) --Removing the part from the parts table. This line can be moved to after the part is changed to the color black if you don't want it to spread past that point
	
	if math.random(1,10) == 1 then
		local explosion = Instance.new("Explosion",workspace)
		explosion.Position = v.Position
		v.Velocity = Vector3.new(0,100,0) --v.Velocity will be underlined with red because it's depricated (not in use)
	end
	fire:Destroy()
	
	wait(math.random(0,1)+10)
	table.remove(_G.ex_parts,table.find(_G.ex_parts,v))
	v:Destroy()
end

function FirePartTouched(Part: BasePart)
	Part.Touched:Connect(function(hit)
		if not table.find(_G.parts,Part) then return end --Stop the code if the part is not in the burning parts table
		if not table.find(_G.parts,hit) and hit.Anchored ~= true and not (game.Players:GetPlayerFromCharacter(hit.Parent) or game.Players:GetPlayerFromCharacter(hit.Parent.Parent)) and not table.find(_G.ex_parts,hit) then --I replaced the name check with table check so the part can keep it's original name
			table.insert(_G.parts,hit)--Adding the part to the table so the touch function can only be applied once
			_G.TurnPartIntoFire(hit) --Turning the part into fire and deleting it later
		end
		if hit.Parent ~= nil and hit.Parent:IsA("Model") then
			local hum = hit.Parent:FindFirstChild("Humanoid")
			if hum then
				hum.Health -= 5
			end
		end
	end)
end

FirePartTouched(StartingPart) --Applying these to the starting part because it won't run otherwise, you can also choose to wait with adding this
_G.TurnPartIntoFire(StartingPart)

Fire tool script: (DOES work)

script.Parent.Activated:Connect(function()
	local fire = Instance.new("Part",workspace)
	fire.Size = Vector3.new(1,1,1)
	fire.Shape = "Ball"
	fire.Position = script.Parent.Handle.Position
	_G.TurnPartIntoFire(fire)
end)

Nuke script: (DOES NOT work)

local bomb = script.Parent

local WAIT = (1/40)/2

for r = 0, 200, 5 do wait(WAIT)
	bomb.Color = Color3.fromRGB(r,17,17)
end

script.Parent.CanCollide = false
script.Parent.Color = Color3.fromRGB(213, 115, 61)
script.Parent.Material = Enum.Material.Neon

script.Parent.Touched:Connect(function(hit)
	if not table.find(_G.parts,hit) and hit.Anchored ~= true and not (game.Players:GetPlayerFromCharacter(hit.Parent) or game.Players:GetPlayerFromCharacter(hit.Parent.Parent)) and not table.find(_G.ex_parts,hit) then
		_G.TurnPartIntoFire(hit)
	end
end)

local ts = game:GetService("TweenService")

local info = TweenInfo.new(
	5,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local goal = {Size = Vector3.new(100,100,100),Transparency = 1}

script.Parent.Anchored = true

local tween = ts:Create(script.Parent,info,goal)
tween:Play()

local au = Instance.new("Sound",script.Parent)
au.SoundId = "rbxasset://sounds\\Rocket shot.wav"
au.Volume = 2
au:Play()
wait(5)
bomb:Destroy()

The fire tool script works perfectly but the nuke script only makes the parts it touches change colour but they dont spread.

Its not good practice to be using _G, or wait().

Why not just do this?

Vector3.one*100
1 Like

This works the same as it did before thanks for the suggestion tho

Also it does not fix the problem