Here's my code:
local rayOrigin = humrp.Position;
local rayDirection = direction.p;
local rayCast = Ray.new(rayOrigin, (rayDirection-rayOrigin).unit*20);
local part = workspace:FindPartOnRay(rayCast, character, false, true);
Where "rayOrigin" is the player's HumanoidRootPart Position and the rayDirection is "mouse.Hit.p"
I assumed the "unit*20" would set the range of the raycast to 20 but I guess I was very wrong haha. The raycast fires a beam that can go as far as it would like. How would I set the range of the ray to 30 studs?
Any help is greatly appreciated! Thanks!

1 comment
Getting the Unit of a Ray gives another Ray with a normalized direction (which would be identical to Ray.new(rayOrigin, (rayDirection-rayOrigin).Unit) ) Afterwards the ray is being multiplied by 20, which would error, so overall accepting this answer isn't correct?