In the picture, the green part has CanCollide disabled to allow players to walk through it (supposed to represent acid pool). The negated area is where the dummy character is standing. All parts you see in the image are one, big union.
The following script is used to cause player to take damage as they walk through the green area, but, as you can see from the dummy’s hit points, the player is also taking damage while in the negated area of the green part. I understand why it’s doing it because the negated area is still a union’ed part to the green part, but my question is, what’s the best way to prevent the touch event firing in a negated area? In this case, preventing a player from taking damage in the negated area.
local pool = script.Parent
pool.Touched:Connect(function(HitPart)
local humanoid = HitPart.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(5)
end
end)
I made a change to where the green part and the concrete part are separate parts and no longer union’ed together. The green part still has the negated area where the concrete is, but I’m still having the same problem. Is there a way to detect if the humanoid is touching or within the concrete area from the green part’s script? Then I can ignore the damage if they are.
I resolved my issue by creating a thin floor and putting the script on that part. Then placed a new part on top of the floor to give enough height to where the floor’s touch event would not fire.
Trying to get the script to detect a player touching part “A” before touching part “B” while in the same area proved to be too unpredictable because part “A” might get touched first or vise-versa.
My redesign works, and probably more efficiently, so I’m good with the outcome.