I got this nifty little script for my tool, and modified it a little to match my preferences. Only problem with the gear is that it doesn't give the player a kill after ending another players life. Any ideas? I tested it with an NPC, and 2 players, but doesn't bump the kill count. Thank you!
local tool = script.Parent
local canDamage = false
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not humanoid then
return
end
if humanoid.Parent ~= tool.Parent and canDamage then
humanoid:TakeDamage(100)
else
return
end
canDamage = false
end
local RESET_SECONDS = .8
local isTouched = false -- Declare debounce variable
local function slash()
if not isTouched then -- Check that debounce variable is not true
isTouched = true -- Set variable to true
local str = Instance.new("StringValue")
str.Name = "toolanim"
str.Value = "Slash"
str.Parent = tool
canDamage = true
wait(RESET_SECONDS) -- Wait for reset time duration
isTouched = false -- Reset variable to false
print("slash")
end
end
tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)
