How to make so player can't deal damage to itself

So I’m editing the classic Time Bomb from Roblox, but I don’t know how to make it so that the time bomb does not kill the player who originally placed the bomb (ex. accidently killing themselves than the other player) I couldn’t find any posts about my issue.

You can create a ForceField inside of the player you want to protect and set the forcefield’s Visible property to false. That way the character can’t really die, but others can and there’s no ugly effect created in the process.

I tested and I still die as soon as the explosion went off

What did you parent the ForceField to? Ideally, if you parent it to the player’s character model, their joints will be protected from the blast and they won’t die.

You cannot really make use of the explosion instance, unless you set it’s damage to 0 globally, then you have to detect touched, once you have done this check if any of the players are the owner. owner.Character and if they are do not damage them.

Then at last calculate the damage either depending the damage or globally.

I parented to the player like you said

How do you set explosions damage to 0? I’m not sure if thats possible

Explosion.DestroyJointRadiusPercent = 0

And for the custom damage:

local MIN_DAMAGE: number, MAX_DAMAGE : number = 25, 75

Explosion.Hit:Connect(function(hit, distance)
    local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
    if hum then
        hum:TakeDamage((1 - distance / Explosion.BlastRadius) * (MAX_DAMAGE - MIN_DAMAGE) + MIN_DAMAGE)

Then for the owner:

local owner: player =
-- inside the function
if owner.Character and owner.Character:FindFirstChildOfClass("Humanoid") == hum then 

Here’s a test script I made to replicate your behavior with an explosion and a ForceField.

	if script.Parent.BrickColor =="Lime green") then"ForceField", player.Character).Visible = false
	end"Explosion", script.Parent).Position = script.Parent.Position

The red button creates an Explosion without creating a ForceField in the character, but the green creates a ForceField in the character and then explodes.

Make sure to delete later else the player will be godded.

you can set a tag for the player and then in the script check for the players tag and if it has that tag, TakeDamage(9)

True, but this script is really just for test purposes to show an example of a Force Field defending a player from the explosion, not meant to be actual complete code.

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