I have made a simple raycast script where the player can create a raycast using their mouse position. The raycast works when the mouse hit position is a normal part, but when it is an ignored part (using raycast parameters exclude option) it tends to be innacurate.
When the mouse hit position is the ignored part vs when it is a non ignored part through the ignored part:

Here is the code:
function Module.Raycast(OriginPosition, TargetPosition, IgnoredDescendants)
local RaycastParameters = RaycastParams.new()
RaycastParameters.FilterType = Enum.RaycastFilterType.Exclude
RaycastParameters.FilterDescendantsInstances = IgnoredDescendants
return workspace:Raycast(OriginPosition, TargetPosition, RaycastParameters)
end
function Module.Create(OriginPosition, TargetPosition, Projectile, IgnoredDescendants)--projectile will be used for wall plug thing
local Direction = (TargetPosition - OriginPosition).Unit
local Distance = (OriginPosition - TargetPosition).Magnitude * 2
local RaycastResult = Module.Raycast(OriginPosition, Direction * Distance, IgnoredDescendants)
if RaycastResult == nil then
print("nil")
else
print(RaycastResult.Position)
local p = Instance.new("Part")
p.Anchored = true
p.CanCollide = false
p.CanQuery = false
p.Color = Color3.fromRGB(255,0,0)
p.Parent = workspace
p.Position = RaycastResult.Position
end
end