Server:
local tool = script.Parent
tool.TakeDamage.OnServerEvent:Connect(function(plr,hum,damage)
hum:TakeDamage(damage)
if hum.Health == 0 then
plr.leaderstats.Kills.Value = plr.leaderstats.Kills.Value + 1
end
end)
Client:
local tool = script.Parent
local equipped = false
local activated = false
local db = false
local db2 = false
local animation
local hum
tool.Equipped:Connect(function()
equipped = true
local char = tool.Parent
hum = char.Humanoid
end)
tool.Activated:Connect(function()
if db == false then
if equipped == true then
if hum then
animation = hum:LoadAnimation(script.Swing)
animation:Play()
activated = true
animation.Stopped:Wait()
activated = false
db = true
wait(1)
db = false
end
end
end
end)
tool.Handle.Touched:Connect(function(hit)
if db == false then
if activated == true then
if hit.Parent.Humanoid then
if hit.Parent.Humanoid ~= script.Parent.Parent.Humanoid then
tool.TakeDamage:FireServer(hum,30)
db = true
wait(1)
db = false
end
end
end
end
end)
tool.Unequipped:Connect(function()
equipped = false
end)
In the end the sword damages ME instead of the enemy, can anyone help solve this?