Explosion does not fling parts, only unanchors

I have an explosion meant to destroy welds and unanchor parts. It does both of those things, but it doesn’t also fling them. Another explosion is required to fling them.

I’m pretty sure I know why it’s happening. I think it’s because the event is firing after the explosion has already tried to fling the parts around it. But I’m just not sure how to fix it.

Part of the script handling the explosion:

NewPrompt.Triggered:Once(function()
		local Explosion = Instance.new("Explosion")
		
		local HitEvent = Explosion.Hit:Connect(function(hit)
			if hit:HasTag("Placeable") then
				hit.Anchored = false
				if hit:FindFirstChildWhichIsA("WeldConstraint") then
					hit:FindFirstChildWhichIsA("WeldConstraint"):Destroy()
				end
			end
		end)
		
		Explosion.Parent = workspace
		Explosion.Position = block.Position
		Explosion.DestroyJointRadiusPercent = 0
		
		Explosion.BlastRadius = 5
		
		task.delay(1, function()
			HitEvent:Disconnect()
		end)
		
		block:Destroy()
	end)

Video of problem:

Maybe create a fake explosion or add a part to list objects that are inside the explosion radius.

I’m not sure, but setting up the Explosion’s parent and position before initializing the HitEvent also might work.

1 Like

I don’t think you have to destroy WeldConstraints with an Explosion (see the link for the explanation), it does it automatically depending on the BlastRadius.

Try parenting the Explosion to the Workspace after you set all the other Properties, instead of doing it first.

1 Like

The property that controls destroying WeldConstraints is a different one called “DestroyJoinRadiusPercent”. I had set this to 0 in my script. Leaving it at 1 actually solves the problem, destroying the welds and sending them flying.
However, I had this set to 0 in the script because if a player gets caught in the explosion when it’s set to 1, they take damage. I don’t want that. Any way you know of to stop damage?
Thanks for the help so far!

It’s in the Explosion link I posted above.
Parent a ForceField to the player Model will protect it.

1 Like

@ActuallyAToaster This is likely because, by the time the shockwaves that happen whenever a part explodes hit the parts, the script isn’t fast enough nor is the physics update to no longer apply the WeldConstraint. What you should do instead of using WeldConstraints as it’s bad practice is use the actual Weld instance.

Also what you could do is have their be an invisible explosion that applies just so you can figure out what parts need to be unanchored then apply another explosion.

The other guys solution works, but I’m curious. Why is using weldconstraints bad practice?

Depends mostly on what you are trying to achieve, if you want to ever animate the parts such as tweeting their positions it can be better to use the Weld rather than WeldConstraints since the Weld will also break if either part is moved allowing for a breakable hinge type idea but up to whatever is the goal for how useful they are.

1 Like