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

My Explosion doesnt deal any damage how to fix?

function onTouched(hit)
		if hit.Name == "Key" or hit.Name == "Torso"	 then
		local e = Instance.new("Explosion")
		e.Parent = game.Workspace
		e.Position = script.Parent.Position
		e.BlastRadius = 3
		e.BlastPressure = 0
		e.BlastDamage = 10
end 
end 

script.Parent.Touched:connect(onTouched)

i thought the blastdamage would work i dont want the destroy joints thing because i dont want insta kill

1 answer

Using the Explosion.Hit event, you can damage a player if they are hit by the explosion:

explosion.Hit:Connect(function(part,distance)
	local damage = 100 / distance -- replace with desired value
	local partParent = part.Parent
	
	local humanoid = partParent:FindFirstChild("Humanoid")
	
	if humanoid then
		humanoid:TakeDamage(damage)
	end
end)

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