How do I get the exact position of a collision?

Hi, I am trying to get the exact position of a Part in a Tool and a Part from the Workspace colliding together. I need the position so I can place something there. I already tried Raycasting but it didn’t seem to work. It always caused errors in the script. To be honest I dont know how to use Raycasting because I never used it before. Do I really need to do that with RayCasting? Or is there a diffrent way?

Here’s a picture so it might be better to understand:

Thanks to anyone who tries to help me in this situation.

2 Likes

If you are Raycasting using workspace:Raycast, If you want the Exact Position on where it Intersected the Object, it would be Result.Position, but if you want it to be outside of the part but touching the Part, you add the Position plus the Normalized Position which is Result.Position + Result.Normal

I already tried many ways like this but when I use anything with Raycasting
(like this):

local RayCastParams = RaycastParams.new()
				local rayOrigin = Touched.Position -- Part in the Workspace
				local rayDirection = script.Parent.Handle.Position -- Part inside a tool inside the character
				local raycastResult = game.Workspace:Raycast(RayCastParams, rayOrigin, rayDirection)

it trows this error:
“Unable to cast Vector3 to RaycastParams”

I also tried to fix it somehow but that didn’t work

Because you are inserting the Values Incorrectly, You have to Apply it in the Correct Order of the Arguments, which it should be in this Order

  • Argument 1: Position:
    The Position to cast the ray

  • Argument 2: Direction:
    The Direction the Ray will go

  • Argument 3 (optional) RaycastParams:
    The Params to Modify the Ray

Instead you are applying the params first, which is incorrect.

3 Likes

RaycastParams is the last argument of workspace:Raycast(), not the first. Try moving “RayCastParams” to the end.

1 Like

I guess that fixed it. I saw some posts where people inserted the params first. So that’s why I taught I need to insert it first.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.