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

How do I make a brick that damages players?

Asked by 10 years ago

How do I make a brick that damages players? Answer below if you know.

-Carlardar

3 answers

Log in to vote
2
Answered by
Sublimus 992 Moderation Voter
10 years ago

You need to run a Touched event on a part, then make sure the toucher is a human, and then damage it:

script.Parent.Touched:connect(function(hit) -- When part is touched
    if hit.Parent:findFirstChild("Humanoid") then -- Check if it is a player
        hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 50 -- Change '50' to how much you want it to damage
    end
end)
Ad
Log in to vote
0
Answered by
yurhomi10 192
10 years ago
script.Parent.Touched:connect(function(hit)
human = hit.Parent:FindFirstChild("Humanoid")

if human then
human:TakeDamage(10) -- change the number in parenthesis to whatever you like
end
end)
Log in to vote
0
Answered by
Hybric 271 Moderation Voter
10 years ago
script.Parent.Touched:connect(function(p)
local x = 50 -- CHANGE THIS TO THE AMOUNT OF DAMAGE
local h = p.Parent:findFirstChild("Humanoid")
if (h ~= nil) then
h:TakeDamage(x)
end
end)

Answer this question