Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can't figure out how to damage NPC and get KO with "no handle" tool? [closed]

Asked by
mrcare -5
6 years ago

This question already has an answer here:

How to damage NPC enemies and get KOs for them?

The problem I'm having is that when I use the punching tool, I want it to damage the NPC only when I left click. And the other problem I'm having is that I have no idea how to increase the amount of KOs on the leaderboard after I [successfully] kill an NPC (and I have a KO counter script already implemented into the NPC which gives a KO if I kill the NPC with another weapon, such as a sword). Keep in mind I'm using a tool with no handle.

What I have so far is my animation portion.

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)

Marked as Duplicate by DeceptiveCaster, Amiaa16, and unmiss

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?