So this is my code and what I am trying to do is that when a diffrent player then the player that activated touches the hitbox this function triggers but it isnt working and there are also no errors
maybe you can still help me.
local NewHitbox = Hitbox:Clone()
NewHitbox.Parent = game.Workspace
NewHitbox.CFrame = tool.Parent.HumanoidRootPart.CFrame*CFrame.new(0,0,-5)
NewHitbox.Touched:Connect(function(hit)
if hitdebounce == false and hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= tool.Parent then
hitdebounce = true
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(5)
task.wait(1)
hitdebounce = false
end
end)
The First two Ifs are returning true, the third is returning false because you are telling it that hit.Parent isnt Tool.Parent, and their Parents are your Character.
When the Event detects the part that’s hitting it, the if statement is looking for a Humanoid within the said part’s parent, If the Player is holding the Tool, the Tool is inside the Character, thus Tool.Parent is your Character,
hit.Parent:FindFirstChild("Humanoid") is looking for the parts Parent that Contains a Humanoid, The Players Character as the parts parent is the Character, and its looking for a Humanoid
So when the part detects the Collusion, inside the if statement its looking for if Hit.Parent is not equal to Tool.Parent, Since they are both your Character, it will return false
That is literally the exact point??
Tool.Parent = YOUR character
Hit.Parent = ANY character including YOURS
If Hit.Parent is equal to YOUR character, then you are hitting yourself. It will return false and thus you WONT damage yourself.
Anyways, I just want to know a few other things. It doesn’t seem like there’s anything wrong with the actual code.
Is this in a local script?
What do the hitbox properties look like?
Are you attacking a dummy, or an actual player?