I'm practicing but not sure how to make a value decrease like say I try to make a brick that makes your health -20 on hit, but not 20 health, just subtracts 20 from your current health. How do I do that? And I assume it would be the same for reflectance or something like that too.
1 | script.Parent.Touched:connect( function (hit) |
2 | print (hit) |
3 | hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 20 --Doesn't work |
4 | end ) |
thanks
01 | local debounce = false |
02 |
03 | script.Parent.Touched:connect( function (obj) |
04 | if debounce = = true then return end --To make it not run all at once when you hit it |
05 |
06 | debounce = true |
07 | if obj.Parent:FindFirstChild( "Humanoid" ) then |
08 | local human = obj.Parent.Humanoid |
09 | human.Health = human.Health - 20 |
10 | end |
11 |
12 | wait(. 2 ) |
13 | debounce = false |
14 | end ) |
1 | game.Workspace.Part.Touched:connect( function (hit) --Rename "Part" with whatever the name is of the brick you want touched. |
2 | print (hit) |
3 | hit.Parent.Humanoid.Health = 0 |
4 | end ) |
This should work.