Raycasting Range Limit

Hello.

I am looking for an effective way to limit the range of travel for bullets in my game.

Here is my current code: (Any help would be appreciated)

local Ignore = {workspace.Ignored, Player.Character}

local Cast = Ray.new(Tool.Handle.Position, Mouse - Tool.Handle.Position)

local Part, Position = workspace:FindPartOnRayWithIgnoreList(Cast, Ignore)
1 Like

The range of a ray is determined by the length of it’s direction - simply make the direction (Mouse - Tool.Handle.Position).Unit * Range in order to add a specific range to it.

1 Like