How to make explosion when part hit wall?

how to make explosion when part hit wall without touched ?

thank you.

local part = script.Parent

part.Touched:Connect(function(hit)
	if hit.Name == "Wall" then
		local explosion = Instance.new("Explosion")
		explosion.Parent = part
		--set other explosion properties here
		task.delay(1, function()
			part:Destroy()
		end)
	end
end)

thank you so much, but Touched has so much bug.

What’s wrong with the .Touched event?

Issue is, what if the part doesn’t hit the intended wall? For example, it could hit the baseplate and/or the character.

The script was just an example anyway, also instead of checking if the hit part is a “Part” instance or a “MeshPart” instance you can simply do the following.

if hit:IsA("BasePart") then --base class for all part instances
	--do code
end
1 Like