How to get the CFrame hit of a ray

How do I get the CFrame of where the ray hits a part? I want to make it where the player will be tp’d to wherever the ray hits something. The error that I get in the output is, “Unable to cast CoordinateFrame to Vector3”
Here’s my current script.

local raycastresult = workspace:Raycast(origin, direction, raycastparams)

		if raycastresult then
			local Position = raycastresult.Position
			player.Character.HumanoidRootPart.CFrame = CFrame.new(Position)
		end
1 Like

If you want to get the EndPosition of a ray just do: ray.Origin + ray.Direction.

Or just go this post: Help finding end point of ray part
To teleport the player just change the HRP Position to the EndPosition you calculated.

The issue seems to be something else, what line did the error occur in? Please indicate with a comment to make it easier for us to debug.

The error occurs in a line from a local script that fires a remote event, the error only occurred whenever i have that line of script in.