Problem while ray the camera lookvector or camera look

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    ?
  2. What is the issue? Include screenshots / videos if possible!
    the issue is the erorr that gave me because idk how to code as always
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    none
wait()
local camera = game.Workspace.CurrentCamera
local direction = (game:GetService("Players").LocalPlayer.character.Head.Position - camera.CFrame.Position).Unit * 350 -- Change 100 to distance
local Parts = {} -- To make visible again
local directio1n = game:GetService("Players").LocalPlayer.character.Head.CFrame.LookVector

game:GetService("RunService").RenderStepped:Connect(function()
	local ray = Ray.new(
		camera.CFrame.LookVector,
		directio1n
	)
	local ignore = game.Players.LocalPlayer.Character -- What to ignore
	local hit, position = workspace:Raycast(ray,directio1n)
	position = hit.Instance
	if hit.Instance == nil then
		hit = nil
	else
		hit  = position
		print(hit.Name)
	end
end)

idk why does it gave me error i just wanna print the parts that are im the camera lookvector or something like that

figured it out that i used Raycast instead of FindRayParts etc but i still wanna print what the camera sees tho

That’s not how to use workspace:Raycast() and that is also not how to use Ray.new().

local RunService = game:GetService("RunService")

local Camera = workspace.CurrentCamera

RunService.RenderStepped:Connect(function()
    local Origin = Head.Position
    local Direction = Camera.CFrame.LookVector * 1000 -- "1000" is the distance the raycast will travel.

    local Params = RaycastParams.new()
    Params.FilterDescendantsInstances = { workspace.PartA,workspace.PartB } -- Put the parts you want it to ignore here.

    local Result = workspace:Raycast(Origin,Direction,Params)
    if Result then
        print(Result.Instance)
    end
end)

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