Hello!
I was working on my “bomb” thingy (With some help on people on dev forum)
and I ran into a problem.
I need the bomb to not bounce off the ground.
Because if the bomb bounces, the explosion will not be on the floor.
Here is my script
--// script made by scpSCARRYY \\--
--// variables \\--
local exploded = false
local bomb = script.Parent
local explodeSound = bomb.explodeSound
local damageMultiplier = bomb.values.damageMultiplier
local bombDamage = bomb.values.damage
bombDamage.Value = bombDamage.Value * damageMultiplier.Value
local hurt = false
--// explosion \\--
function touched(hit)
bomb.Anchored = true
--// will explode if touched ANYTHING \\--
if not exploded then
exploded = true
explodeSound:Play()
bomb.Transparency = 1
bomb.CanCollide = false
bomb.CanTouch = false
--// explosion part \\--
local explosion = Instance.new("Part", game.Workspace)
explosion.Size = Vector3.new(1, 1, 1)
--// tween \\--
local tweenService = game:GetService("TweenService")
local sizeTween = {}
sizeTween.Size = explosion.Size + Vector3.new(10, 10, 10)
local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0)
local tween = tweenService:Create(explosion, tweenInfo, sizeTween)
--// explosion looks \\--
explosion.Name = "explosion"
explosion.Transparency = 0.5
explosion.Shape = Enum.PartType.Ball
explosion.TopSurface = Enum.SurfaceType.Smooth
explosion.BottomSurface = Enum.SurfaceType.Smooth
explosion.Material = Enum.Material.Neon
explosion.Color = Color3.new(1, 0.643137, 0.352941)
explosion.Anchored = true
explosion.CanCollide = false
if hit.Parent:FindFirstChild("Humanoid") then
explosion.Position = hit.Parent.HumanoidRootPart.Position
else
explosion.Position = bomb.Position
end
tween:Play()
--// explosion core \\--
---------------------------------------------------------
--// explosion core \\--
local core = Instance.new("Part", game.Workspace)
core.Size = Vector3.new(0.5, 0.5, 0.5)
--// tween \\--
local sizeTween2 = {}
sizeTween2.Size = explosion.Size + Vector3.new(5, 5, 5)
local tweenInfo2 = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0)
local tween2 = tweenService:Create(core, tweenInfo2, sizeTween2)
core.Name = "explosion core"
core.Shape = Enum.PartType.Ball
core.TopSurface = Enum.SurfaceType.Smooth
core.BottomSurface = Enum.SurfaceType.Smooth
core.Material = Enum.Material.Neon
core.Color = Color3.new(1, 1, 1)
core.Anchored = true
core.CanCollide = false
core.Position = explosion.Position
tween2:Play()
--// connect damage script when touched explosion \\--
explosion.Touched:Connect(damage)
wait(0.5)
exploded = false
core:Destroy()
explosion:Destroy()
bomb:Destroy()
end
end
--// damage \\--
function damage(hit)
if hit.Parent ~= nil then
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum and not hurt then
hurt = true
hum.Health -= bombDamage.Value
end
end
end
--// make explosion when bomb is touched \\--
bomb.Touched:Connect(touched)
And here is what happens
Any help is appreciated.
