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

Make a part that can kill players but not the one that casted it?

Asked by 7 years ago

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.

01card.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)

1 answer

Log in to vote
0
Answered by 7 years ago

You never reset debounce. Typically the code is:

1debounce = true
2--action here
3wait(0.1) -- or whatever cooldown you like
4debounce = 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.

0
Thanks ScriptAbyss 10 — 7y
0
If you find an answer helpful you should accept it as the answer so people know that your problem has been solved chess123mate 5873 — 7y
Ad

Answer this question