Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Explosion.hit does not work when I try to make explosion.hit worK?

I was making TNT for a voxel building game. And for some reason Explosion.Hit doesn't work. All blocks have a size of (4, 4, 4).

local explosion = Instance.new("Explosion")
explosion.BlastRadius = 20
explosion.Position = tnt.Position
explosion.DestroyJointRadiusPercent = 0

print("caiedskm")

explosion.Hit:Connect(function(p, d)
	print(p.Name) --nothing prints when I touch explosion
	
	if p.Parent:FindFirstChild("Humanoid") then
		p.Parent.Humanoid.PlatformStand = true
	end
	
	if not p.Anchored then
		if d == 0 then d = 0.1 end
		
		p.Velocity = p.Velocity + (p.Position - explosion.Position) / d * 300 --explosion does not send parts flying at a unrealistically high velocity
	end
	
	if string.sub(p.Name, 1, 5) == "part " then
		print("Found part on explosion")
		local attr = string.split(p.Name, " ") --terrain block names go by "part (x) (y) (z)" (in grid space)
		workspace.ExplosionOnCell:Fire(tonumber(attr[2]), tonumber(attr[3]), tonumber(attr[4]))
	end
end)

explosion.Parent = workspace

tnt:Destroy()

P.S. "caiedskm" is just some random letters I typed. I wrote the line to see if print was working.

P.P.S. The terrain blocks are anchored. I'm not sure if that affects the hit event.

3 comments

0

If nothing is printed when the tnt explodes, then the explosion probably isn't where you thought it was or there is nothing within the blast radius. I just don't see any other way the explosion would not hit anything.

0

Does it output an error?

0

No it doesn't output anything. And I can see the explosion centered on the TNT, and the TNT is placed on top of a block when it explodes.

1 answer

Tried setting the parent of explosion as a different part all together, just welded to the TNT or something of the such?

1 comment

0

This belongs in the comments, it is not an answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.