I've completed the animation process of my punch tool [as seen below], but can't get around damaging NPC's only when clicking and figuring out how to get a KO on the leaderboard after killing them. Keep in mind I'm using a "handless" tool.
local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:wait() local tool = script.Parent local swingsound = tool:WaitForChild("Swing") tool.Activated:connect(function() local choose = math.random(1,3) if choose == 1 then local swing1animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch1) swingsound:Play() swing1animation:Play() elseif choose == 2 then local swing2animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch2) swingsound:Play() swing2animation:Play() elseif choose == 3 then local swing3animation = script.Parent.Parent.Humanoid:LoadAnimation(script.Punch3) swingsound:Play() swing3animation:Play() end end) tool.Unequipped:connect(function() local hum = char:WaitForChild("Humanoid") end)
To deal damage to a target humanoid you want to a touched event, then check if what you touched has a humanoid inside of it.
LeftHand.Touched:Connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid") then Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(Number) end end)
now to increase damage do
LeftHand.Touched:Connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid") then Hit.Parent:FindFirstChild("Humanoid"):TakeDamage(Number) if Hit.Parent:FindFirstChild("Humanoid").Health <= 0 then Player.leaderstats.KOS.Value = Player.leaderstats.KOS.Value + 1 end end end)
sorry if the code is slightly off, im writing on mobile