Sword ablitysssssssasd

thank you guyssasdadsasdzzzzzadsasd

2 Likes

You could put a Value inside the NPC called “NPC” then when the sword touches something, you will check if a value named “NPC” is inside the model. If there is a value then do the damage to the NPC however if it doesn’t find the NPC value then it wont do damage because it was not an NPC.

1 Like

He could just use

local Target = game.Players:GetPlayerFromCharacter(hit.Parent)

if not Target then
-- code
elseif Target then
-- ignore
end
3 Likes

Before you do damage with the sword, you can check whether the sword is hitting the NPC and not another player.

One way to handle this:

--this is a serverscript. If using this in a localscript, you have to make some sort of remote event to handle the damage serverside.
local tool = script.Parent --assuming the script is placed directly inside the tool
local handle = tool.Handle --or any other variable path to get the handle
local damage = 20

handle.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("NPC") and hit.Parent:FindFirstChild("NPC"):IsA("Humanoid") then --assuming the humanoid is called NPC
        Humanoid.Health = Humanoid.Health - damage
    end
end)
1 Like

Just check if it’s a player or not.

local Players = game:GetService("Players")
local Handle = script.Parent --Assuming the Script is inside the Handle
local damage = 0

Handle.Touched:Connect(function(part)
    if Players:GetPlayerFromCharacter(part.Parent) then
        return
    end
    local Humanoid = part.Parent:FindFirstChildWhichIsA("Humanoid")
    
    if Humanoid and Humanoid.Health > 0 then
        Humanoid:TakeDamage(damage)
    end
end)
12 Likes