As the title said, originally I had this being used for my script
local function DetectObject()
local cameraRay = Ray.new(Character.Head.Position, Camera.CFrame.Position - Character.Head.Position)
local Ignore = {Character}
local HitPart, HitPosition = game.Workspace:FindPartOnRayWithIgnoreList(cameraRay, Ignore)
Camera.CFrame = (Camera.CFrame - (Camera.CFrame.Position - HitPosition)) + (Character.Head.Position - Camera.CFrame.Position).Unit
end
Then I tried to switch it to raycast by doing it like this,
local function DetectObject()
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {Character}
raycastParams.IgnoreWater = true
local raycastResult = workspace:Raycast(Character.Head.Position, Camera.CFrame.Position - Character.Head.Position, raycastParams)
if raycastResult then
local hitPosition = raycastResult.Position
Camera.CFrame = CFrame.new(Camera.CFrame.Position - (Camera.CFrame.Position - hitPosition)) + (Character.Head.Position - Camera.CFrame.Position).Unit
end
end
well, it turned to disaster, Im not sure whats wrong with the script or how am I even supposed to convert it, I’d appriciate any help really