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

How to make blocks like lava kill humanoids?

Hello there, I was making an Obby and I was at the lava jumps part but I don't know how to make the script of lava jumps so can u show me the script and explain how the script works so I can do it by myself.

1 comment

0

yes look on answers

2 answers

This is pretty easy. All you have to do is make a script in the part you want to kill the player. Then insert this

script.Parent.Touched:Connect(function(hit)
	local character = hit.Parent
	local human = character:FindFirstChild("Humanoid")
	local player = game.Players:GetPlayerFromCharacter(character)
       
	if player and human.Health > 0  then 
		human.Health = 0 
	end
end)

So what this script does is. First we connected the part with .Touched event.

The .Touched event will return us the part that touched the lava part.

Once we have what touched the lava part we need to check if the part is the player, so we get the character by getting the Parent of the part, then we use character:FindFirstChild("Humanoid") to get the Humanoid that contains the Health of the character and we get game.Players:GetPlayerFromCharacter(character) to get the player from the character.

Now that we have all we need we do an if statement to check if its a player and its not dead then kill the player by changing its health to 0.

  1. local boostPart = script.Parent
  2. -- Set a variable for boosted jump power
  3. local BOOSTED_JUMP_POWER = 250
  4. local function onPartTouch(otherPart)
  5. local partParent = otherPart.Parent
  6. local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
  7. if humanoid then
  8.  boostPart.CanCollide = false
    
  9.  local currentJumpPower = humanoid.JumpPower
    
  10. if currentJumpPower < BOOSTED_JUMP_POWER then
    
  11. humanoid.JumpPower = BOOSTED_JUMP_POWER
    
  12.     boostPart:Destroy()
    

13 wait(10) 14. humanoid.JumpPower = currentJumpPower 15. end 16. end 17. end

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