How to get current x,y cframe of camera

  1. What do you want to achieve? Keep it simple and clear!
    im experimenting and im trying to make a reflections script
  2. What is the issue? Include screenshots / videos if possible!
    i think i know how to do it but i don’t know how to get the current x,y cframe of the camera/pixel of the screen it’s checking for, im not sure how to explain properly
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i looked in dev hub but i don’t know how to properly explain what i mean so it showed me stuff that didn’t help me

code i currently have:

local dist = 35
function getRay(startcf: CFrame)
	local norm = startcf.LookVector
	local pos = startcf.Position
	local r = workspace:Raycast(pos,norm*dist)
	if r then
		local reflected = norm - (2*norm:Dot(r.Normal)*r.Normal)
		norm = reflected
		local reflectedthing = workspace:Raycast(pos,norm*dist)
		return reflectedthing, r
while wait(1) do
	for x = 1,script.Parent.Frame.AbsoluteSize.X do
		for y = 1,script.Parent.Frame.AbsoluteSize.Y do
			local reflected, origin = getRay()--here it needs the cframe
			if reflected and origin then
				if origin.Instance.Reflectance > 0.1 then
					local f ="Frame",script.Parent)
					f.Size =,1,0,1)
					f.BackgroundColor3 = reflected.Instance.Color
					f.Position =,x,0,y)
local camera = workspace.CurrentCamera
local cameraPosX = camera.CFrame.Position.X
local cameraPosY = camera.CFrame.Position.Y
local cameraPosZ = camera.CFrame.Position.Z

no i meant like the x,y position of the pixel its currently raying for


i don’t think that’s what i meant either
anyway i figured it out, i just needed to swap the cframe for 2 vector3s, one is position one is lookvector and for the position one i needed to do workspace.CurrentCamera.CFrame.Position* x), y/(max y), 1)
except i dont think it works, it doesnt generate the grass below(it only generates some kind of wheel of a car), i dunno if theres any error in the getRay function or in the position getter thing, ill try to fix that or idk

so this apparentely has nothing to do with getRay function, i did print it in output and even tho i gave it the return function it printed that the reflected ray from the instance is nil even tho in function it does print it exists

nevermind i give up ima try that on surface guis

CFrame has a lot of values, maybe :lookat will help you?