I want to cast a ray that can go through any part until it collides with a specific part. How would I do that?
This is my current ray cast script. “Target” is the part that I want the ray to collide with.
local RayOrigin = ball.Position
local RayDirection = MouseHit.Position - RayOrigin
local RaycastParams = RaycastParams.new()
RaycastParams.FilterDescendantsInstances = {game.Workspace.Target}
RaycastParams.FilterType = Enum.RaycastFilterType.Whitelist
local Ray = workspace:Raycast(RayOrigin, RayDirection, RaycastParams)