Hi I need some help with making a sword, that doesn't one hit players. I tried fixing it so many times but It wont work. I need some help! Here is my script:
local sword = script.Parent debounce = 2 notfree = false local function slash() if notfree == false then sword.blade.Touched:Connect(function(hit) human = hit.Parent:FindFirstChild("Humanoid") if human then human:TakeDamage(20) end notfree = true end) end end sword.Activated:Connect(slash) sword.Deactivated:Connect(function() wait(debounce) notfree = false end)
Just change
human:TakeDamage(20)
to
human:TakeDamage(100)
The problem is that your sword is hitting the other player multiple times when it slashes.
There is a simple fix for this but sometimes it can be inconsistent.
The fix is adding a cooldown when the sword touches a player. This makes it so that if your sword touches a player, it will start the cooldown and all the following touches will be ignored until the cooldown ends.
local sword = script.Parent debounce = 2 cooldown = false notfree = false local function slash() if notfree == false then sword.blade.Touched:Connect(function(hit) human = hit.Parent:FindFirstChild("Humanoid") if human then if cooldown == false then cooldown = true human:TakeDamage(20) wait(0.1) cooldown = false end end notfree = true end) end end sword.Activated:Connect(slash) sword.Deactivated:Connect(function() wait(debounce) notfree = false end)
If this doesn't work then make the waiting time for the cooldown longer