Problem with "bomb" not staying in place

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.

maybe try the custom properites on the model’s parts and make them all besides Density and friction 0 or close to

I will try this. Thanks for the reply

This does not work. I tried making everything 0, everything max, everything in the middle, it just didnt do anything.

I think you need to anchor your bomb after it hits the floor

You need to set the elasticity to 0, or try to make the bomb a ton heavier so it doesn’t bounce.

Look at the script. I already did that. It doesnt work.

How would I make it heavier? I dont know how.

You would need to set the elasticity to 0, and the friction to a value above 1.

Ok. I will try that… hopefully it works

It kinda works… the bomb doesnt bounce, but the explosion is still above the ground.

Maybe instead put the position of the explosion at the bomb’s X and Z, but Y just above the floor. This will prevent the explosion from following the Y axis of the bomb, so it will always be at the floor. However, if your floor changes height in some places, you would need raycasts instead.

Oof… exactly how hard are raycasts to use?

They are not that hard to use.

So the script isn’t the problem it is the CustomPhysicalProperties. Set Elasticity = 0 and set ElasticityWeight to 10
robloxapp-20221108-1018150.wmv (286.6 KB)

Okay. I will try this too… Hopefully it works (again)

Okay. I will try this… hopefully it will work

It works now, I will set the first post to solution because it also worked. I will just use raycasting

1 Like

Do you need help with using raycasts?

…Probably. I will try and figure it out myself, though…

1 Like