local tool = script.Parent
function Damage(Hit)
Hit.Parent.Humanoid:TakeDamage(25)
end
tool.LeftSwing.OnServerEvent:Connect(function()
local con
con = tool.Hitbox.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
Damage(Hit)
con:Disconnect()
end
end)
end)
tool.RightSwing.OnServerEvent:Connect(function()
local con
con = tool.Hitbox.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
Damage(Hit)
con:Disconnect()
end
end)
end)
function Damage(Hit)
Hit.Parent.Humanoid:TakeDamage(25)
end
tool.LeftSwing.OnServerEvent:Connect(function()
local con
con = tool.Hitbox.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
Damage(Hit)
con:Disconnect()
print(con)
end
end)
end)
tool.RightSwing.OnServerEvent:Connect(function()
local con
con = tool.Hitbox.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
Damage(Hit)
con:Disconnect()
print(con)
end
end)
end)
tool.RightSwing.OnServerEvent:Connect(function()
local con
con = tool.Hitbox.Touched:Connect(function(Hit)
con:Disconnect()
if Hit.Parent:FindFirstChild("Humanoid") then
Damage(Hit)
print(con)
end
end)
end)
Honestly, in my opinion, this is the most efficient way to use the touch function.
local rs = game:GetService(“RunService”)
local canHit = false
local sword = script.Parent.Handle
function damage()
canHit = true
wait(0.5)
canHit = false
end
–// You can have your remote event wrapped around this function.
sword.Touched:Connect(function(hit)
if canHit then
local found
found = hit.Parent:FindFirstChild("Humanoid")
if found then
found:TakeDamage(20)found = nil
else
print(found)
canHit = false
end
rs.Heartbeat:Wait()
canHit = false
end
end)