This script takes away 100 health. I want it to take away 50%
1 | script.Parent.Touched:connect( function (Obj) -- When you touch it gets the "Leg" or "Arm" |
2 | local Player = game:GetService( "Players" ):GetPlayerFromCharacter(Obj.Parent) |
3 | -- Gets the Instance "Player" |
4 | if Player and Player.Character then -- Obv its gonna be there... |
5 | local Humanoid = Player.Character:WaitForChild( "Humanoid" ) -- Find the Humanoid |
6 | Humanoid:TakeDamage( 50 ) -- Easy damage function.. :) |
7 | end |
8 | end ) |
you need a debounce, you hit a part like 1 million times in a second, it probaly works, the script is called tonns of times
01 | debounce = false |
02 | script.Parent.Touched:connect( function (Obj) |
03 | if debounce = = false then |
04 | debounce = true |
05 | local Player = game:GetService( "Players" ):GetPlayerFromCharacter(Obj.Parent) |
06 | if Player and Player.Character then |
07 | local Humanoid = Player.Character:WaitForChild( "Humanoid" ) |
08 | Humanoid:TakeDamage( 50 ) |
09 | wait( 3 ) |
10 | debounce = false |
11 | end |
12 | end |
13 | end ) |
:) try this for half damage
01 | debounce = false |
02 | script.Parent.Touched:connect( function (Obj) |
03 | if debounce = = false then |
04 | local Player = game:GetService( "Players" ):GetPlayerFromCharacter(Obj.Parent) |
05 | if Player and Player.Character then |
06 | local Humanoid = Player.Character:WaitForChild( "Humanoid" ) |
07 | local damage = Humanoid.Maxhealth/ 2 |
08 | Humanoid:TakeDamage(damage) |
09 | debounce = true |
10 | end |
11 | end |
12 | end ) |