Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

how can you create a killbrick? [closed]

Asked by 5 years ago

(Those blocks that kill you when you touch them)

1
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. IcyEvil 260 — 5y
0
sorry, bored OBenjOne 190 — 5y
0
Why wasn't moderation taken against this question? Jexpler 63 — 5y
0
I am moderating against it. IcyEvil 260 — 5y

Closed as Not Constructive by Leamir, Vulkarin, IcyEvil, and green271

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
1
Answered by
OBenjOne 190
5 years ago
Edited 5 years ago

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!
0
hopefully nothing in my code is decrepit I will look connect up... OBenjOne 190 — 5y
0
is it Connect or connect? I really forgot OBenjOne 190 — 5y
0
Both connect and Connect work, but I believe 'Connect' is the one that will be fixed if broken. IcyEvil 260 — 5y
Ad
Log in to vote
0
Answered by
IcyEvil 260 Moderation Voter
5 years ago

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