yes i already did a sword but this one is updated so here's the problem animations are working and it does damage but there's a leader board in my game and when ever the player gets killed it gives 6 kills and 6 deaths please help!
local t = script.Parent
local owner = t:WaitForChild("owner")
local b = t:FindFirstChild("blade")
local mindmg = 5
local maxdmg = 30
t.Equipped:Connect(function()
local char = t.Parent
owner.Value = char.Name
end)
b.Touched:Connect(function(p)
local char = p.Parent
if char:FindFirstChild("Humanoid") then
local hum = char:FindFirstChild("Humanoid")
hum:TakeDamage(math.random(mindmg,maxdmg))
hum.Died:Connect(function()
local killer = owner:Clone()
killer.Parent = hum.Parent
for _, p in pairs(game.Players:GetPlayers()) do
if p.Name == killer.Value then
local kstats = p:WaitForChild("leaderstats")
local kills = kstats:WaitForChild("Kills")
kills.Value = kills.Value + 1
end
end
local killedplr = game.Players:GetPlayerFromCharacter(hum.Parent)
local kstats2 = killedplr:WaitForChild("leaderstats")
local deaths = kstats2:WaitForChild("Deaths")
deaths.Value = deaths.Value + 1
end)
end
end)
its not the best cause I don't really return or what "creator" is so sorry if it's bad
