I’m having a problem with the Touched
function, it’s not recognizing the npc, I use a similar script in a tool to damage it, but the skills are not working, I really don’t know the reason, I tried for print (Hit)
to see the objects that touch and do not paint anything that is part of the Dummy (NPC).
this is my script (located on ServerScriptService)
local HumanoidsDamaged = {}
local char = plr.Character;
rock.Touched:Connect(function(hit)
local HitedChar = hit.Parent
local HitedHum = HitedChar:FindFirstChild("Humanoid")
if not HumanoidsDamaged[HitedChar] then
if HitedHum then
HumanoidsDamaged[HitedChar] = 1
if HitedChar ~= char and game.Players:FindFirstChild(HitedChar.Name) then
HitedHum:TakeDamage(TakeDmgPlayer)
elseif HitedHum:FindFirstChild("GiverEvent") then
ChangeHealth(plr,HitedHum,TakeDmgDummy)
end
end
end
end)
(the Npc’s damage is not the same as the player’s so there are two damage variables!)