Im trying to make a part that kill the other players when touched but not the player that used it. Here is the script but its not working.
01 | card.Touched:Connect( function (hit) |
02 | if not debounce then |
03 | if hit and hit.Parent then |
04 | print (hit.Parent.Name) |
05 | if not hit.Parent.Name = = player.Character.Name then |
06 | local hum = hit.Parent:FindFirstChild( 'Humanoid' ) |
07 | if hum then |
08 | hum:TakeDamage( 2 ) |
09 | debounce = true |
10 | end |
11 | end |
12 | end |
13 | end |
14 | end ) |
You never reset debounce. Typically the code is:
1 | debounce = true |
2 | --action here |
3 | wait( 0.1 ) -- or whatever cooldown you like |
4 | debounce = false |
A superior version of line 5 is if not player == game.Players:GetPlayerFromCharacter(hit.Parent) then
, as then it won't matter what things are named.