So what I’m trying to do is exclude the player from the touched event.
What the touched event does is makes a “fake raycast” which I have already set up and it works perfectly fine, although It does hit the player since it isn’t a ray. Is there anyway to exclude the “shooter” from the shot/hit/getting hit?
I have already tried that too and there was also no luck.
BTW there is no point in doing if not *Insert thing* == *Insert other thing* then, you only need to do if *Insert thing* ~= *Insert other thing* then
function FakeRayForGuns(Player, Hit, Damage)
if Hit ~= nil and Hit.Parent.Name ~= Player.Name then
if Player.Character:FindFirstChild("LowerTorso") ~= nil then
if Hit.Name == "Head" or Hit.Name == "Handle" then -- Handle for accessories
Hit.Parent:FindFirstChild("Humanoid").Health = Hit.Parent:FindFirstChild("Humanoid").Health - Damage
end
end
end
end
Yes, it is a function.
I call the function inside the .Touched event.
function FakeRayForGuns(Player, Hit, Damage)
if Player.Name ~= Hit.Parent.Name then
if Hit.Name == "Head" then
Hit.Parent.Humanoid.Health = Hit.Parent.Humanoid.Health - Damage
elseif Hit.Name == "Handle" then
Hit.Parent.Humanoid.Health = Hit.Parent.Humanoid.Health - Damage
end
end
end