I’m trying to make a bomb that functions similarly to the one seen in the “Bomber Dash” series.
It kind of works, but it only makes an explosion on the right axis, rather than all of them and it displays this error:
I have no clue what it’s talking about.
BombHandler Script:
---///[Variables]\\\---
local BombEvent = game.ReplicatedStorage:WaitForChild("BombEvent")
local BombModel = game.ReplicatedStorage:WaitForChild("Bomb")
local ExplosionBlock = game.ReplicatedStorage:WaitForChild("Explosion")
---///[Settings]\\\---
bombticks = 3
-------------------------------
canGoRight = true
canGoLeft = true
canGoForward = true
canGoBackward = true
local function FireX(Position)
for i = 1, 2 do
local RayCastOrigin = Position + Vector3.new(6*i, 0, 0)
local RayCastParams = RaycastParams.new()
RayCastParams.FilterType = Enum.RaycastFilterType.Blacklist
RayCastParams.FilterDescendantsInstances = {workspace.Players}
local Result = workspace:Raycast(RayCastOrigin, Vector3.new(0,-10,0), RayCastParams)
if Result and Result.Material ~= Enum.Material.Slate and Result.Material ~= Enum.Material.SmoothPlastic and Result.Material ~= Enum.Material.WoodPlanks and canGoRight == true then
local Explosion = ExplosionBlock:Clone()
Explosion.Parent = workspace
Explosion.Position = Position + Vector3.new(6*i, 0, 0)
game:GetService("Debris"):AddItem(Explosion, 1)
elseif Result.Material == Enum.Material.WoodPlanks and canGoRight == true then
local Explosion = ExplosionBlock:Clone()
Explosion.Parent = workspace
Explosion.Position = Position + Vector3.new(6*i, 0, 0)
game:GetService("Debris"):AddItem(Explosion, 1)
local Crate = Result.Instance
Crate.Transparency = 1
Crate.CanCollide = false
else
canGoRight = false
end
end
for i = 1, 2 do
local RayCastOrigin = Position + Vector3.new(-6*i, 0, 0)
local RayCastParams = RaycastParams.new()
RayCastParams.FilterType = Enum.RaycastFilterType.Blacklist
RayCastParams.FilterDescendantsInstances = {workspace.Players}
local Result = workspace:Raycast(RayCastOrigin, Vector3.new(0,-10,0), RayCastParams)
if Result and Result.Material ~= Enum.Material.Slate and Result.Material ~= Enum.Material.SmoothPlastic and Result.Material ~= Enum.Material.WoodPlanks and canGoLeft == true then
local Explosion = ExplosionBlock:Clone()
Explosion.Parent = workspace
Explosion.Position = Position + Vector3.new(6*i, 0, 0)
game:GetService("Debris"):AddItem(Explosion, 1)
elseif Result.Material == Enum.Material.WoodPlanks and canGoLeft == true then
local Explosion = ExplosionBlock:Clone()
Explosion.Parent = workspace
Explosion.Position = Position + Vector3.new(6*i, 0, 0)
game:GetService("Debris"):AddItem(Explosion, 1)
local Crate = Result.Instance
Crate.Transparency = 1
Crate.CanCollide = false
else
canGoLeft = false
end
end
end
local function FireZ(Position)
for i = 1, 2 do
local RayCastOrigin = Position + Vector3.new(0, 0, 6*i)
local RayCastParams = RaycastParams.new()
RayCastParams.FilterType = Enum.RaycastFilterType.Blacklist
RayCastParams.FilterDescendantsInstances = {workspace.Players}
local Result = workspace:Raycast(RayCastOrigin, Vector3.new(0,-10,0), RayCastParams)
if Result and Result.Material ~= Enum.Material.Slate and Result.Material ~= Enum.Material.SmoothPlastic and Result.Material ~= Enum.Material.WoodPlanks and canGoForward == true then
local Explosion = ExplosionBlock:Clone()
Explosion.Position = Position + Vector3.new(0, 0, 6*i)
game:GetService("Debris"):AddItem(Explosion, 1)
elseif Result.Material == Enum.Material.WoodPlanks and canGoForward == true then
local Explosion = ExplosionBlock:Clone()
Explosion.Position = Position + Vector3.new(0, 0, 6*i)
game:GetService("Debris"):AddItem(Explosion, 1)
local Crate = Result.Instance
Crate.Transparency = 1
Crate.CanCollide = false
else
canGoForward = false
end
end
for i = 1, 2 do
local RayCastOrigin = Position + Vector3.new(0, 0, -6*i)
local RayCastParams = RaycastParams.new()
RayCastParams.FilterType = Enum.RaycastFilterType.Blacklist
RayCastParams.FilterDescendantsInstances = {workspace.Players}
local Result = workspace:Raycast(RayCastOrigin, Vector3.new(0,-10,0), RayCastParams)
if Result and Result.Material ~= Enum.Material.Slate and Result.Material ~= Enum.Material.SmoothPlastic and Result.Material ~= Enum.Material.WoodPlanks and canGoBackward == true then
local Explosion = ExplosionBlock:Clone()
Explosion.Position = Position + Vector3.new(0, 0, -6*i)
game:GetService("Debris"):AddItem(Explosion, 1)
elseif Result.Material == Enum.Material.WoodPlanks and canGoBackward == true then
local Explosion = ExplosionBlock:Clone()
Explosion.Position = Position + Vector3.new(0, 0, -6*i)
game:GetService("Debris"):AddItem(Explosion, 1)
local Crate = Result.Instance
Crate.Transparency = 1
Crate.CanCollide = false
else
canGoBackward = false
end
end
end
---///[On Event Fired]\\\---
BombEvent.OnServerEvent:Connect(function(Player, Root)
local RayCastOrigin = Root.Position + Root.CFrame.LookVector * 6
local RayCastParams = RaycastParams.new()
RayCastParams.FilterType = Enum.RaycastFilterType.Blacklist
RayCastParams.FilterDescendantsInstances = {workspace.Players}
local Result = workspace:Raycast(RayCastOrigin, Vector3.new(0,-10,0), RayCastParams)
if Result and Result.Material ~= Enum.Material.Slate and Result.Material ~= Enum.Material.SmoothPlastic and Result.Material ~= Enum.Material.WoodPlanks then
local Bomb = BombModel:Clone()
Bomb.Parent = workspace.BombCache
Bomb.Position = Result.Instance.Position + Vector3.new(0,6,0)
for i = 1, bombticks do
task.wait(1)
Bomb.Tick:Play()
Bomb.Size += Vector3.new(0.5,0.5,0.5)
end
Bomb.Transparency = 1
Bomb.Boom:Play()
FireX(Result.Instance.Position + Vector3.new(0,5,0))
FireZ(Result.Instance.Position + Vector3.new(0,5,0))
Bomb:Destroy()
canGoRight = true
canGoLeft = true
canGoForward = true
canGoBackward = true
end
end)