New raycasting functions - how do I get a hitpos?

So the old raycasting system I could get a hitpos even if it didn’t hit anything, how can I achieve a similar thing to this:

while NotHit == true do
			local timeSinceLastFrame = game:GetService("RunService").Heartbeat:Wait()
			local ray =, Cframe.LookVector * speed * timeSinceLastFrame)
			hit,hitpos,normal = game.Workspace:FindPartOnRayWithIgnoreList(ray,ignore)
			Projectile.Position = hitpos +,offset),math.random(0,offset),0)
			origin = hitpos

It casts a ray then I move it to the hitpos and offset it, but i’m not sure how to do that with the new raycasting function.

Logically, if the ray didn’t hit anything, the “position” is the origin + the direction.

1 Like