How do I create a part on the size and position and angle of a raycast weather it hit something or it did not

It basically casts a ray from where the bullet comes from to the Mouse’s pointing direction. If it finds something it will make the ray visible making a line which always starts from where the bullet comes to the Ray’s intersection with the Result. If there is no result, the line will go up to the range, which in this example is 300 studs.

I have been recently watching this thing called :ViewportPointToRay and the similar one, I think these might be the solution to my problem they use deprecated raycasts tho…

No no no you got me all wrong I dont wanna create a part where the raycast hits, I wanna create a part the size, position and lenght and angle of the raycast, And I want this to be done weather the raycast hit something or not.

I tried it and uhhh it didnt worked

It didnt created a part like it was mean to:

No output errors

heres the code

I of course just changed 2 values to the propper ones wich were the variable names I had for those

Ill try and use it some way altho dont understand most of it.

Run service???
Proppertysignal local player???
local distance = pos 1 what? and what is magnitude
what mid Point???
NewPart.CFrame = CFrame.lookAt(MidPoint, pos 2) ???

local intesection is what?

Ok my brain hurts, imma go learn all of these things and then come back with you to see if your script works

maybe because RayCastResult is false? try adding print and check if it would pass the statement

alright and also my system mainly needs to depend in raycasts not getting results since not always you will hit a wall or a player with the raycast.