-
What do you want to achieve? Keep it simple and clear!
im experimenting and im trying to make a reflections script -
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 -
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
end
end
while wait(1) do
script.Parent.Frame:ClearAllChildren()
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 = Instance.new("Frame",script.Parent)
f.Size = UDim2.new(0,1,0,1)
f.BackgroundColor3 = reflected.Instance.Color
f.Position = UDim2.new(0,x,0,y)
end
end
end
end
end