So You Want To Make A Kill Brick, Eh?
Posted on April 21, 2015 by DrJonJ
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!
function deathTouch(part) end 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.
function deathTouch(part) if part then end end 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).
function deathTouch(part) if part then local plr = game.Players:GetPlayerFromCharacter(part.Parent) if plr then end end end script.Parent.Touched:connect(deathTouch)
Now we just need to call BreakJoints() on the character.
function deathTouch(part) if part then local plr = game.Players:GetPlayerFromCharacter(part.Parent) if plr then plr.Character:BreakJoints() end end end script.Parent.Touched:connect(deathTouch)
And if you just want to do a certain amount of damage, replace the code with
local touchers = { } function deathTouch(part) if part then local plr = game.Players:GetPlayerFromCharacter(part.Parent) if plr then local hum = plr.Character:FindFirstChild('Humanoid') if hum then local found; for _,v in pairs(touchers) do if v == plr.Name then found = true end end if found then return end -- don't double damage hum:TakeDamage(20) table.insert(touchers, plr.Name) wait(1) local caught; for _,z in pairs(touchers) do if z == plr.Name then caught = _ end end table.remove(touchers, caught) end end end end 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