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

Why am i not dying when i step on the brick?

Asked by 6 years ago
script.Parent.Touched:Connect(function(hit)
    if script.Parent:FindFirstChild("Humanoid") then
        script.Parent.Humanoid.Health = 0
    end
end)script.Parent.Touched:Connect(function(hit)
    if script.Parent:FindFirstChild("Humanoid") then
        script.Parent.Humanoid.Health = 0
    end
end)
1
You need to find the humanoid on the hit's parent, not on the block that is being touched. Rheines 661 — 6y

4 answers

Log in to vote
0
Answered by
tacotown2 119
6 years ago
Edited 6 years ago
    script.Parent.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then -- hit.Parent the thing that hits it the parent of it so the player then find humanoid in the player
           hit.Parent.Humanoid.Health = 0 -- same here
        end
    end)
0
dang it I didn't see this Mr_Unlucky 1085 — 6y
Ad
Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
6 years ago

You put script instead of hit.

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.Health = 0
    end
end)
Log in to vote
0
Answered by 6 years ago

Try this.

local damage = 100 --Default damage for lava based objects.
script.Parent.Touched:Connect(function(object)
if object.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid:TakeDamage(damage)
Log in to vote
0
Answered by
hoth7 45
6 years ago

this script will make it work!

function onTouched(hit) local human = hit.Parent:findFirstChild("Humanoid") if (human ~= nil) then human.Health = human.Health - 100 end end script.Parent.Touched:connect(onTouched)

Answer this question