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

How to make a player killing part?

Asked by 3 years ago

Give me instruction or script how to do it?

0
pretty sure the toolbox has like 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 models of these lmao. in fact theres one i made in my inventory if you wanna check that out, it expands too greatneil80 2647 — 3y

4 answers

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Hello! So, making a kill part is very simple. Simply, create a LOCAL script inside the part. Inside the LocalScript, insert this code:

local part = script.Parent --defines part

part.Touched:Connect(function(hit) --gets function
    local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid") --finds humanoid

    if humanoid then --checks that humanoid was found
        humanoid:TakeDamage(100) --kills humanoid, also killing the player
    end --ends if statement
end) --ends function

What it does is it gets the part, detects when it gets hit, then gets the humanoid. If it finds the humanoid, it kills the humanoid, causing the player to get killed as well.

Hope this helps!

Ad
Log in to vote
0
Answered by 3 years ago

You have to insert a part with a script into the workspace, and use this to check when the something has touched the part. You can easily find one on the internet, just search around a little before going onto here.

Log in to vote
0
Answered by
danklua 72
3 years ago
Edited 3 years ago
local Part=workspace["PARTNAMEHERE"]

Part.Touched:Connect(function(Player)
if Player:IsA("BasePart") and Player.Parent:IsA("Model") and Player.Parent:FindFirstChildWhichIsA("Humanoid") then
Player.Parent:BreakJoints()
end
end)

Simply just change "PARTNAMEHERE" in the script to the name of your part or if you put the script inside the part change

local Part=workspace["PARTNAMEHERE"]

to

local Part=script.Parent
0
This is an out-dated way. NickyPlayz2011 82 — 3y
Log in to vote
0
Answered by 3 years ago

Hi! First, insert a Script inside the part that are gonna kill the player. This is the script:

local KillPart = script.Parent

KillPart.Touched:Connect(function(hit) 
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent:WaitForChild("Humanoid").Health = 0
    end
end)

It's a very simple script. It works perfectly for me. Let me know if that script also worked for you!

Answer this question