Explosion keeps on happening in a different spot, Why?

Hello! so i got this atomic bomb script:

local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://165969964"
sound.Volume = 1
local boom = Instance.new("Explosion")
boom.ExplosionType = Enum.ExplosionType.Craters
boom.Name = "boom"
boom.Visible = true
boom.BlastPressure = 500000
boom.BlastRadius = 90
boom.DestroyJointRadiusPercent = 1
script.Parent.Touched:Connect(function(hit)
	hit.Color = Color3.new(0.337255, 0.337255, 0.337255)
	hit.Material = Enum.Material.CorrodedMetal
	local part = Instance.new("Part")
	part.Name = "BOOMPART"
	part.Parent = game.Workspace
	part.CFrame = script.Parent.CFrame
	boom.Parent = part
	sound:Play()
	script.Parent:Destroy()
end)

and it works but everytime the bomb explodes the explosion happens in a different spot everytime. Why?

You should set the position of the explosion to the part

-- before parenting explosion to part
boom.Position = part.Position

You need to add debounce to your code otherwise you will have BOOMPART’s all over the place when you touch your main part which might be why the explosions happen in different spots.

You do need a debounce as @quakage said, but another reason it could be is that the part you are spawning is not anchored, so when the explosion happens, it launches the part causing the visual concern. When the part launches the explosion follows it as well. That and your script doesnt delete the parts afterwards so it will get pretty hectic.

i anchored the parts and did what vector said so idk whos right, so thank you Dabbing, quakage, vector for helping!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.