(Those blocks that kill you when you touch them)
how can you create a killbrick?
2 answers
fairly simple:
script.Parent.Touched:connect(function(hit) -- gets the killbrick, and runs this code when it is touched
if hit and hit.Parent:FindFirstChild("Humanoid") then -- finds out if it hit a humanoid (aka character NPC or other model with a humanoid)
hit.Parent.Humanoid.Health = 0 -- kill
end
end)
this script should be in a part
EDIT: A bit more information. The way killbricks usually work is to first use a Touched connect function to detect when the killbrick hits or is hit by another part (on line 1) afterwords, it finds out whether the thing that hit it was part of a player (not the player object) and then changes the player's humanoid health to 0, killing it. Note: you can change values other than Health:
hit.Parent.Humanoid.WalkSpeed = 50 -- superspeed!
or
hit.Parent.Humanoid.JumpPower = 200 -- super jump!
3 comments
hopefully nothing in my code is decrepit I will look connect up...
is it Connect or connect? I really forgot
Both connect and Connect work, but I believe 'Connect' is the one that will be fixed if broken.
Well, it's really simple really. First you must have a brick, and add a script inside of this brick.
In the script you'll need to add this line.
script.Parent.Touched:connect(function(hit)
end)
this says 'when this brick is touched something will happen'. Now we need to add a few lines checking to see if what is touching it is 'alive'.
script.Parent.Touched:connect(function(hit)
if hit.Parent then -- new line that I added
local hum = hit.Parent:FindFirstChild("Humanoid") -- new line that I added
if hum then -- new line that I added
else -- new line that I added
print("Not human") -- new line that I added
end -- new line that I added
end -- new line that I added
end)
What I just did checked to see if one, the part was touched, and if whatever touched said part has a Humanoid inside of it, otherwise it will print to the output/console that it isn't 'Human'. Now what we need to do is well kill it if it is human.
script.Parent.Touched:connect(function(hit)
if hit.Parent then
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then -- new line that I added
print("Is Human") -- new line that I added
hum.Health = 0 -- new line that I added
else
print("Not human")
end
end
end)
Now if it is human, it will put in the output or console saying that it is human, and then kill it as well.
Now remember next time, not to ask us to make a script for you, that is not the purpose of this website, our purpose is to HELP you with your script that YOU have already attempted to make. As the name is ScriptingHelpers and not ScriptCreators
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
We do not work for you, you must make your own attempt at the script and then if it doesn't work you ask for help, with the script added.
sorry, bored
Why wasn't moderation taken against this question?
I am moderating against it.