You can write your topic however you want, but you need to answer these questions:
I want to make a sphere move forward if its not seen on the camera, but its not working.
It isnt moving, or working.
I have seen the original poster of this code’s post. But it didnt work.
Here is my code:
local part = workspace.SunCopy
local cam = workspace.CurrentCamera
local isOnScreen = select(2, cam:WorldToViewportPoint(part.Position))
local function myCode()
script.Parent.Position = script.Parent.Position + script.Parent.CFrame.LookVector*3
end
while task.wait() do
--check if on screen, if not, return end.
if isOnScreen then
myCode();
else return end
end
Dunno why you’d use select(). WorldToViewportPoint returns a vector and a boolean. You want the boolean which is if you can see the point or not so change the isOnScreen variable to this:
local vector, isOnScreen = cam:WorldToViewportPoint(part.Position)