Explosion inconsistently working on unanchored parts

I wrote a system for dropping unanchored parts into a container, and then allowing the player to create an explosion inside of that container to make the parts fly out of it.

The first few explosions work as intended, but then it breaks and the parts no longer get flung.

Video of issue:

Server Code:

		local root = workspace.ExplosionPart
		local explosion = Instance.new("Explosion")
		explosion.BlastRadius = 200
		explosion.BlastPressure = 10000000
		explosion.Position = root.Position
		explosion.DestroyJointRadiusPercent = 0
		explosion.Parent = root
		rs.RemoteEvents.OnExplosion:FireAllClients(explosion)

Client code:

rs.RemoteEvents.OnExplosion.OnClientEvent:Connect(function(explosion)
	explosion.BlastPressure = 0
end)

I’d have to imagine the issue is related to setting the blastpressure to 0 on the client, which is purposeful (I don’t want players getting flung, only the unanchored meshes).

Found a solution using Explosion.Hit, but am still looking for any other solutions that may be better.

local function createExplosion()
	local explosion = Instance.new("Explosion")
	explosion.BlastPressure = 3000000
	explosion.DestroyJointRadiusPercent = 0
	explosion.BlastRadius = 200
	explosion.Position = workspace.ExplosionPart.Position
	explosion.Visible = false
	
	local alreadyHit = {}
	
	explosion.Hit:Connect(function(part, distance)
		local model = part.Parent
		if model then
			if alreadyHit[model] then
				return
			end
			
			alreadyHit[model] = true
			
			local humanoid = model:FindFirstChild("Humanoid")
			if humanoid then
				model.HumanoidRootPart.Anchored = true
				task.wait(.1)
				model.HumanoidRootPart.Anchored = false
			end
		end
	end)
	
	explosion.Parent = workspace
end
1 Like

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