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

Can someone help me make a brick that when touched does 17 damage to player?

Asked by 6 years ago

im trying to make a script so that when you touch a part, it damages you (-17 health) here is what ive tried with what i learned so far, but it doesnt work plz help

    repeat
    game.Workspace:FindFirstChild(script.Parent.Touched).Humanoid.Health = game.Workspace:FindFirstChild(script.Parent.Touched).Humanoid.Health-17
    until script.Parent.TouchEnded

Plz help Dx

0
I would urge you to look for free models and to read and comprehend the scripts yourself. The script you're showing us right now is meaningless. XAXA 1569 — 6y
0
wow rlly helpful, Thanks C: *sarcasme* lukebloxdaily 6 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Put this script inside of a brick/part.

script.Parent.Touched:Connect(function(part)
    local humanoid = part.Parent:FindFirstChild("Humanoid") -- if the part finds a humanoid, we know it's a player touching the brick
    if (humanoid ~= nil) then -- if the humanoid exists
        humanoid:TakeDamage(17) -- damage the humanoid by 17
    end
end)
0
it works, but i want it to damage you like every 3 seconds and when i stop touching it, it still damages me :/ lukebloxdaily 6 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
script.Parent.Touched:Connect(function(part)
CantTouchMe=false
    local humanoid = part.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil and CantTouchMe==false) then 
        humanoid:TakeDamage(17) -- damage the humanoid by 17
    CantTouchMe=true
wait(3)
CantTouchMe=false
    end
end)

0
same problem, it glitches like every mili-second it goes from 63 to 120-160 lukebloxdaily 6 — 6y

Answer this question