local = debounce
Player = script.Parent.Parent
c = Player.Character
Sword = Instance.new("Part")
Sword.Parent = c
SwordMesh = Instance.new("SpecialMesh")
SwordMesh.MeshId = "rbxassetid://432068544"
SwordMesh.Parent = Sword
Sword.CanCollide = false
w1 = Instance.new("Weld", c)
w1.Part0 = w1.Parent["Right Arm"]
w1.Part1 = Sword
w1.C1 = CFrame.fromEulerAnglesXYZ(1.5,0,1.4) *CFrame.new(0,1.2,2)
function onSliced(Target) --Changed the variable.
if debounce == false then
debounce = true
if Target.Parent:FindFirstChild("Humanoid") then --Locating Humanoid.
if game.Players:GetPlayerFromCharacter(Target.Parent) ~= Player then --Now that we confirmed it was a character model, compare it to if the player is the target.
Target.Parent.Humanoid.Health = Target.Parent.Humanoid.Health - 5.5 --Reduce health. ForceFields will not respect this method. I would recommend using function TakeDamage().
print("Hit")
wait(1)
debounce = false
end
end
end
Sword.Touched:connect(onSliced)
--It works fine but When My sword touches a humanoid It does damage multiple times I tried adding debounce but that just breaks the script any help?
this is how I added it(debounce)
COMMUNITY QUESTION
Why does this keep repeating the damage?
0 answers
No public answers were preserved for this question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Could have left the question in the comments of the question I answered for one thing. Another thing, you need to add a debouce or some variable to check to prevent a user from being hit too quickly. You can add this yourself. How are you adding the debounce?