In this tutorial, we’ll show you how to make a kill part script
in Roblox Studio.
Here is a video of this tutorial on YouTube:
Here is a link to this “game” if you want to test it on Roblox:
https://www.roblox.com/games/7960821717/How-to-Make-a-Kill-Part-or-Lava
This is useful if you want to put lava in a game that will kill
a player when they touch it.
Step 1: Open Roblox Studio and create a new game from a template.
Step 2: In the Model tab, click on part to create a new block.
You can resize this part by clicking the scale button and dragging
the red, green or blue bubbles on each side.
If you would like to add a color to your part, select
it and choose a color in the properties window.
You can also add a decal to make it look more realistic by searching
for a lava image in the Toolbox on the left.
Once you find a lava image that looks good, simply drag it to
your part. You may have to repeat this process so the decal
shows on sides.
Now, add a spawn location near your part to make
testing easier.
Step 3:
Now it’s time to add a script to your part.
Select the part and it will be highlighted in the explorer
window.
Hover your mouse over the part and click the plus sign on the
right, then click Script.
Now, the part will have a script associated with it.
delete the default hello world script and add the following Lua code.
For your convenience, I have posted this code in the description
of this video.
–BEGIN CODE
local lava = script.Parent
local function killPlayer(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChild(“Humanoid”)
if humanoid then
humanoid.Health = 0
end
end
lava.Touched:Connect(killPlayer)
–END CODE
After adding the code, you can click the x button next to the script name
to make sure the script is saved.
Now, click the play button to test your game.
When you touch or walk on the lava, your player will die.
And that’s all there is to it.
If you have any questions or need additional help with this tutorial, please
leave a comment on the companion YouTube video “Kill Part Script for Roblox Studio: 2021” and
and we’ll be happy to help.