So I want to detect when a part is on screen, or not, but with my current script, it has a small issue. Even if a section of the part is on screen, the actual position isn’t, so it will detect the part as off screen, and I’m not sure how to fix this:
Local script, inside of StartCharacterScripts:
local RunS = game:GetService("RunService")
RunS.RenderStepped:Connect(function(dt)
for _, part in pairs(workspace:GetDescendants()) do
if part:IsA("Part") then
local vector, inScreen = workspace.CurrentCamera:WorldToViewportPoint(part.Position)
if inScreen then
part.LocalTransparencyModifier = 0.5
print("yes")
else
part.LocalTransparencyModifier = 1
print("no")
end
end
end
end)
Any help is appreciated!