I'm working on this camera part script thingy. Basically what it does (or what I'm trying to make it do) is make a part's transparency set to 1 whenever the part is in the ray of the camera. My issue here is that whenever I move my camera past a part (that's still in camera's ray) it prints nothing, however, if my camera is just close to a part (not inside it but just around the surface of a part), it prints "part was within ray!" I'm not much of a smarty when it comes to rays so I was wondering if anyone could see what I'm doing wrong or give me some info on making this function as it should. Thank you!
Code:
local cam = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local RootP = Character:WaitForChild("HumanoidRootPart")
local Ignore ={Character}
game:GetService("RunService").RenderStepped:Connect(function()
local RayL = Ray.new(cam.CFrame.Position, (RootP.Position).unit)
local Part, pos = game.Workspace:FindPartOnRayWithIgnoreList(RayL, Ignore, false, true)
if Part then
print("part was within ray!") --at the moment I just want to see if the camera is inside a part
else
end
end)
