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

How can I make it so when a player touches a brick, they die?

Asked by 10 years ago

I need help doing this. I am gonna make an obby.

6 answers

Log in to vote
3
Answered by
ultrabug 306 Moderation Voter
10 years ago

You can use the Touched event with a part like so:

part.Touched:connect(function(hit)

And then you can find out if the part belongs to a player like this:

humanoid=hit.Parent:FindFirstChild("Humanoid")
if humanoid ~=nil then

And then you can use your favorite method for killing a player, here is mine:

hit.Parent.Torso:Destroy()

And then all together we have this:

part.Tocuehd:connect(function(hit)--Touched event!
    humanoid=hit.Parent:FindFirstChild("Humanoid")--Finding the Humanoid!
    if humanoid ~=nil then--If the humanoid exists!
        hit.Parent.Torso:Destroy()--Killing the player!
    end
end)
Ad
Log in to vote
0
Answered by 10 years ago

Use a script that upon touch humanoid health = 0

In obbies, people like chances, so make it upon touch damage humanoid 30 to 40

Log in to vote
0
Answered by 10 years ago

You can use this script:

function Touched(hit)
humanoid-hit.Parent.findFirstChild("Humanoid")
if Humanoid ~=nil then
Instance.new("Part, Head")
hit.Head:Destroy()
end
end

script.Parent.onTouched:connect(hit)
0
I am a dev myself (please check out my games btw) and the script I use is this one 6_09x 0 — 3y
Log in to vote
0
Answered by
stix619 15
10 years ago

Hello Allisaurus!

This simple script will kill a player on touch.

The green text explains what each part does.

bin = script.Parent --This is a variable. We can use this later, in the function.

function onTouched(Part2) --This is the function.
    local h = Part2.Parent:FindFirstChild("Humanoid") --We are searching for the player's body here.
    if h then --If it is there, then....
        while h.Health > 0 do --Check if it's health is greater than zero. I'm not sure if this is needed, but I keep it anyway.
        h.Health = h.Health - 100 --Take away the player's health.
        wait(1) --Waits a second. Probably not needed either, but whatever.
        end
    end
end --Ends the function.

bin.Touched:connect(onTouched) --This connects the function.

I hope this helps. Good luck with your obby!

Log in to vote
0
Answered by
6_09x 0
3 years ago

script i use is function onTouch(part) local humanoid = part.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil) then -- if a humanoid exists, then humanoid.Health = 0 -- damage the humanoid end end

script.Parent.Touched:connect(onTouch)

0
and put it on the part so like add a script to the part 6_09x 0 — 3y
Log in to vote
-1
Answered by 10 years ago

It's easy, you would just need a upontouched(), and a function to take the players health down to zero. On free models, there are loads of scripts that do exactly that.

0
Free models? Pfffffffft 6_09x 0 — 3y

Answer this question