Inaccurate raycast result position

The code:

local function detectPlayer()
	local plrMousePosition = plr:GetMouse().Hit.Position

	local params = RaycastParams.new()
	params.FilterDescendantsInstances = {plr.Character}
	params.FilterType = Enum.RaycastFilterType.Exclude

	local origin = workspace.CurrentCamera.CFrame.Position
	local direction = (plrMousePosition - origin).Unit * 10000

	local raycastResult = workspace:Raycast(origin, direction, params)

	if raycastResult then
		local part = Instance.new("Part")
		part.Parent = workspace
		part.Position = raycastResult.Position
		part.Anchored = true
		part.CanCollide = false

		game.Debris:AddItem(part, 1)
	end
end

Some useful things:

  • Im using a custom Over The Shoulder camera module
  • It sets the CameraType to Scriptable (when i make a part to put to the camera cframe position its on point so the camera shouldnt be the issue)

This is how it looks with roblox default camera (no bugs)

This is how it looks with the OTS camera module:

Idk, could this be an issue with the crosshair gui or something?

Yes its an issue with the crosshair gui

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.