RayCasting is very inaccurate when raycasting downwards

I am helping a friend work on a small system where you click on a tool and it will raycast downwards for it to find a spot for it to place. (We decided on raycasting so it can’t be placed in the air or inside some sort of terrain.) The script currently sort of works, however the position from the RaycastResult is off by like 10ish studs.

This is the code that raycasts and places the item.

local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = { plrcharacter }
		
local hrpposition = script.Parent.Parent.HumanoidRootPart.Position
local Result = workspace:Raycast(hrpposition, hrpposition - Vector3.new(0, 100, 0), params)
		
print(Result.Position) 
print(hrpposition) -- HRP position is completely different from Result.Position
if Result then
	local Deployer = script["Deployer"]:Clone()
			
	Deployer.Parent = game.Workspace
	Deployer:SetPrimaryPartCFrame(CFrame.new(Result.Position))
end

Could someone provide me a reason why it doesn’t work?

1 Like

This isn’t correct. You’re trying to specify the direction of the ray, not the ending point. Remove the hrpposition and keep the `-Vector3.new(0, 100, 0).

2 Likes

Ah I see, how would I specify the ending point for the position directly underneath the HumanoidRootPart then? Disregard.