local Debounce = false
local ChangeStateNumber = 0
local Sword_Module = {}
function Sword_Module.Slash(ToolName, PPC,plr)
local char = workspace:WaitForChild(plr.Name)
local Humanoid = char:WaitForChild("Humanoid")
if not Debounce and ChangeStateNumber == 0 then
Debounce = true
ChangeStateNumber = 1
local blacklist = {}
for i,v in pairs(workspace.Mobs:GetDescendants()) do
if v:IsA("Model") then
local direction = v.HumanoidRootPart.Position - char.HumanoidRootPart.Position
local raycastresuly = workspace:Raycast(char.HumanoidRootPart.Position,direction)
if raycastresuly.Instance then
if raycastresuly.Distance < 5 and raycastresuly.Instance ~= workspace:WaitForChild(plr.Name) then
raycastresuly.Instance.Parent.Humanoid:TakeDamage(10)
print(raycastresuly)
else
print("To far!")
end
end
end
end
script["sword slash"]:Play()
Humanoid.Animator:LoadAnimation(script.Slash1):Play()
script["Sword Swish 102 (SFX)"]:Play()
wait(0.6)
Debounce = false
ChangeStateNumber = 0
end
end
return Sword_Module
the code above is what i am doing i am trying to make the raycast only damage npcs but it damages the player. how could i fix this?