hey i need help with a quick script! when u touch a part and u loose 25 health and if u touch it again u lose another 25 health Help!
Put this script in a Part
If this works please accept my answer.
01 | local debounce = false |
02 | local HealthLoss = 25 -- Change this to the damage you need. |
03 | function OnTouched(Part) |
04 | if Part.Parent ~ = nil then --Keep Parentless blocks from breaking it. |
05 | if debounce = = false and Part.Parent:findFirstChild( "Humanoid" ) ~ = nil then |
06 | debounce = true |
07 | Part.Parent:findFirstChild( "Humanoid" ):TakeDamage(HealthLoss) |
08 | wait( 2 ) --Wait two seconds before the brick can hurt someone. |
09 | debounce = false |
10 | end |
11 | end |
12 | end |
13 | script.Parent.Touched:connect(OnTouched) |
man, I'll give you this script, but this isn't a website where you just ask for a script and pronto, you need to put in effort yourself. Insert inside the part this script:
1 | script.Parent.Touched:connect( function (hit) |
2 | if hit and hit.Parent and hit.Parent:FindFirstChild( "Humanoid" ) then |
3 | hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25 |
4 | end |
5 | end ) |
I won't give you it next time if you don't put forth any effort.