I have a game with 2 tools; one called FireThrow which throws small fireballs. When it hits something it turns what it hits into fire and it spreads. However, for my other tool, BigFireThrow, it creates an explosion and everything in the explosion radius turns into fire but it does not spread. I don’t know what I’m doing wrong.
FireThrow script:
game.Debris:AddItem(script.Parent,5)
local mod = require(game.ServerScriptService.ModuleScript)
script.Parent.Touched:Connect(function(hit)
mod.TurnPartIntoFire(hit)
end)
BigFireThrow script:
game.Debris:AddItem(script.Parent,10)
local mod = require(game.ServerScriptService.ModuleScript)
wait(.1)
script.Parent.Touched:Connect(function()
local impact = Instance.new("Explosion",workspace)
impact.Position = script.Parent.Position
local rad = math.random(5,10)
impact.BlastRadius = rad
impact.BlastPressure = math.random(10000,100000)
-- annoyingly, i have to use ALL of these to make it actually turn the parts into fire
impact.Hit:Connect(function(hit)
mod.TurnPartIntoFire(hit)
mod.FirePartTouched(hit)
end)
local parts = workspace:GetPartBoundsInRadius(script.Parent.Position,rad)
for _, v in pairs(parts) do
mod.TurnPartIntoFire(v)
mod.FirePartTouched(v)
end
--
script.Parent:Destroy()
end)
Fire module:
local module = {}
module.parts = {}
module.ex_parts = {}
function random(min,max)
return math.random(min*1000,max*1000)/1000
end
module.TurnPartIntoFire = function(v: BasePart)
if (not table.find(module.ex_parts,v) and not table.find(module.parts,v)) and v.Anchored == false and v.Parent and not (game.Players:GetPlayerFromCharacter(v.Parent) or game.Players:GetPlayerFromCharacter(v.Parent.Parent)) then
print(v.Name)
game.Debris:AddItem(v,random(5,10))
-- stage 1
table.insert(module.parts,v)
local mat = v.Material
v.Material = Enum.Material.Neon
v.Color = Color3.fromRGB(math.random(155,255), math.random(55,100), math.random(20,50))
local fire
if not v:FindFirstChildWhichIsA("Fire") then
fire = Instance.new("Fire",v)
fire.Size = (v.Size.X+v.Size.Y+v.Size.Z)/3
else
fire = v:FindFirstChildWhichIsA("Fire")
end
fire.Color = v.Color
v.Anchored = false
v:BreakJoints()
--wait(random(0,2))
module.FirePartTouched(v)
--wait(random(1,5))
if math.random(1,10) == 1 then
local explosion = Instance.new("Explosion",workspace)
--explosion.Visible = false
explosion.Position = v.Position
explosion.BlastRadius = math.random(5,15)
explosion.BlastPressure = math.random(10000,1000000)
v.Velocity = Vector3.new(0,100,0)
explosion.Hit:Connect(function(hit)
module.TurnPartIntoFire(hit)
end)
end
v:Destroy()
--[[ stage 3
v.BrickColor = BrickColor.new("Black")
v.Material = mat
table.insert(module.ex_parts,v)
table.remove(module.parts,table.find(module.parts,v))
if math.random(1,10) == 1 then
local explosion = Instance.new("Explosion",workspace)
explosion.Position = v.Position
explosion.BlastRadius = math.random(5,15)
explosion.BlastPressure = math.random(10000,1000000)
v.Velocity = Vector3.new(0,100,0)
explosion.Hit:Connect(function(hit)
module.TurnPartIntoFire(hit)
end)
end
fire:Destroy()]]
end
end
function fired(hit)
if not table.find(module.parts,hit) and hit.Anchored ~= true and not (game.Players:GetPlayerFromCharacter(hit.Parent) or game.Players:GetPlayerFromCharacter(hit.Parent.Parent)) and not table.find(module.ex_parts,hit) then
wait(random(0,1))
module.TurnPartIntoFire(hit)
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
module.FirePartTouched = function(Part: BasePart)
local parts = workspace:GetPartBoundsInBox(Part.CFrame,Part.Size*1.1)
for _, v in pairs(parts) do
fired(v)
end
Part.Touched:Connect(function(hit)
if not table.find(module.parts,Part) then return end
fired(hit)
end)
end
return module
Any and all suggestions are appreciated. Thank you!