What solutions have you tried so far? (Have you searched for solutions through the Roblox Wiki yet?)
I’ve checked the wiki and unsuccesfully found a answer to my problem
It seems to me that your Grid Height is just short enough that the ray is not able to reach the baseplate. If a ray doesn’t hit anything, then hitpos will be the origin of the ray plus the direction (including the length of the direction)
If I’m correct, that’s why the red dots appear to hit the baseplate correctly, when in reality they don’t quite make it
If you ever have problems with raycasting, I always find that visualising the Ray helps a lot.
You can do this with the following code:
local PartRay = Instance.new(“Part”)
local Distance = Vector3.new(StartPosition, Position).magnitude
PartRay.Size = Vector3.new(1,1,Distance)
PartRay.CFrame = CFrame.new(StartPosition,Position) * CFrame.new(0,0,-StartPosition/2)
This will draw a part along the ray from the start to the end. You can then use that to determine what the Ray is hitting and why you’re not getting the results you wanted.