Hey there! The Doc here, and today I'm doing to show you how to make a kill brick. Please note that this is a simple thing, but this was my application blog post so I wanted to share it. Thanks!
First, open Studio and insert a part using the context menu via right clicking.
Now select that part, and make it how you like. I made mine like lava.
Now highlight the part, and insert a script via the context menu.
This first method is going simply removing (destroy really) their head. To do that, we need to Add a touch event to the script. Open the script, and add the following. Feel free to name the function whatever your want!
1 | function deathTouch(part) |
5 | script.Parent.Touched:connect(deathTouch) |
Currently that's an empty function. First, we need to see if the part that hit it is still there.
1 | function deathTouch(part) |
9 | script.Parent.Touched:connect(deathTouch) |
If it's still there, it'll continue just fine. If not, it'll just stop running.
Next, we need to check if a player touched it. I use a nifty function called (this is also a link to the function on the wiki) GetPlayerFromCharacter(model).
01 | function deathTouch(part) |
04 | local plr = game.Players:GetPlayerFromCharacter(part.Parent) |
12 | script.Parent.Touched:connect(deathTouch) |
Now we just need to call BreakJoints() on the character.
01 | function deathTouch(part) |
04 | local plr = game.Players:GetPlayerFromCharacter(part.Parent) |
06 | plr.Character:BreakJoints() |
12 | script.Parent.Touched:connect(deathTouch) |
And if you just want to do a certain amount of damage, replace the code with
03 | function deathTouch(part) |
06 | local plr = game.Players:GetPlayerFromCharacter(part.Parent) |
08 | local hum = plr.Character:FindFirstChild( 'Humanoid' ) |
11 | for _,v in pairs (touchers) do |
16 | if found then return end |
18 | table.insert(touchers, plr.Name) |
21 | for _,z in pairs (touchers) do |
26 | table.remove(touchers, caught) |
33 | script.Parent.Touched:connect(deathTouch) |
In that last script there was quite a few things added, but I'll get into that in another post. I should also note that it is more extensive since it will not allow someone to get damaged twice in a one second period. Feel free to change the damage within the TakeDamage(20)
section, and if you don't want a time out, just put a 0 for the wait(1)
.
That's it! Now admire your work, then go ahead and save it to your models! See you next time!
Commentary
Leave a Comment