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

How do I make a explosion not kill a person instead do -20 damage ?

So you know the explosion

instance.new('Explosion')

but what i have noticed is that whenever A explosion happens i tend to die no matter what health i have.

is there any way to make it so that the explosion instead of just killing me does -20 damage?

1 comment

0

u can make a explosion ur self aka a projectile

2 answers

This is because the explosion property Explosion.DestroyJointRadiusPercent, set to 1 by default. Because this is set to 1, the player death occurs as a result of their neck joint breaking.

if you want to damage the player without killing them, set Explosion.DestroyJointRadiusPercent to 0 and use the Explosion.Hit event to handle the result of the explosion.

https://developer.roblox.com/api-reference/class/Explosion/

1 comment

0

Try elaborating more on answering the question. Maybe note on how you could take advantage of the TakeDamage function.

Server Script

local explosion = Instance.new("Explosion")
explosion.DestroyJointRadiusPercent = 0 -- Prevents Joint Breaks
explosion.BlastPressure = 30 -- Sets Velocity of Hit Parts
explosion.BlastRadius = 50 -- Determines Range of Explosion
explosion.ExplosionType = Enum.ExplosionType.NoCraters -- Determines Debris Removal
explosion.Parent = workspace

local debounce = true

explosion.Hit:Connect(function(hit, distance)
	if debounce == false then return end
	debounce = false
	local human = hit.Parent:FindFirstChild("Humanoid")
	if human then
		human:TakeDamage(20)
		wait(0.5)
	end
	debounce = true
end)

Each of the properties are defined for you in the script. the "hit" of the explosion is any basepart. Since the player's character is made up of more than one basepart, you will have to use a debounce to make sure that the damage is only taken once.

1 comment

0

Don't feed code without explaining how the code works and why.

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