Parts that Make Players Explode

Parts that Make Players Explode

Mar 30 2021, 5:23 AM PST


You want to make the person who touches a part explode.


Use the Explosion object.

	if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
		local exp = Instance.new('Explosion')
		exp.Position = hit.Position
		exp.Parent = workspace


We start with a standard BasePart/Touched connection and check if hit.Parent is a character, using the Players/GetPlayerFromCharacter method of the Players service. By doing this we can ensure that whatever hit the part was part of a Player (we don’t want to explode when another part touches it, just when a player touches it). Within the conditional we instantiate an Explosion object and parent it to the Workspace. Then we set the BasePart/Position property of the explosion the the Position property of the object that touched the part.

Without setting the Position property correctly, we would get an explosion happening in the center of the map. Positioning will be covered in great detail later on.

  • particles