Position of contact on a .Touched function?

Is there some kind of parameter on .Touched that returns the position where a part was touched?
If so, I really need it…

2 Likes

U return the pos.
script.Parent.Touched:Connect(function(part)
print(part.Position)
end)

I mean the position where a part was touched, not the position of the part touched.

Please ensure that you follow Scripting Support category guidelines when requesting help. Your thread is relatively vague and there’s no indication that you’ve searched or attempted to resolve this problem. If you had searched and gone to the BasePart.Touched documentation, you’ll notice that no such parameter exists. You’ll have to calculate this yourself.

Worth the stretch, but have you attempted to compare the relative CFrame of the part in contact to the one that’s checking for the contact?

part.Touched:Connect(function (otherPart)
    local contactPoint = part.CFrame:ToObjectSpace(otherPart.CFrame)
    -- Do something here
end)

@DrakeNightingale Returning the other part’s position doesn’t give you a contact point and magnitude won’t give you the result you’re looking for, since that’s for equations requiring distance.

4 Likes

The difficulty in this type of question is that collision between two parts likely cannot be defined as just one point of contact.

Take for example the idea of two equal sized parts stacked on top of each other. In that case any point on the two colliding surfaces would be considered a point of contact; that’s an infinite number of points!

Could you perhaps explain what you’re trying to do with it?

2 Likes

If you want the exact point at which something touches something I’d recommend Raycasting.

1 Like

I suppose what u can do is on contact get a vector between the part that touched it and the actual part itself. From there cast it as a ray and have it whitelist only the part that collided. Make the origin of the ray in a sense be the part which collided. Then from there its just ray.Position