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.

card.Touched:Connect(function(hit)
        if not debounce then
            if hit and hit.Parent then
                print(hit.Parent.Name)
                if not hit.Parent.Name == player.Character.Name then
                    local hum = hit.Parent:FindFirstChild('Humanoid')
                        if hum then
                        hum:TakeDamage(2)
                        debounce = true
                    end
                end
            end
        end
    end)

1 answer

Log in to vote
0
Answered by 7 years ago

You never reset debounce. Typically the code is:

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

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