For some reason the Terrain is being ignored by the function WorldToViewportPoint(), but the BaseParts are being detected normally. There’s any other way to get the Terrain being detected?
local function isPointVisible(worldPoint)
local camera = workspace.CurrentCamera
local _, onScreen = camera:WorldToViewportPoint(DarkGhost.HumanoidRootPart.Position)
if onScreen then
print("Object on Screen?")
local origin = camera.CFrame.p
local ray = Ray.new(origin, worldPoint - origin)
local hit = workspace:FindPartOnRay(ray)
if hit then
print("Hitting the location?")
return false
end
else
print("Ghost not on screen, getting obstructed by objects")
return false
end
print("Getting obstructed?")
return true
end
isPointVisible(DarkGhost.HumanoidRootPart.Position)
task.wait(0.1)
end)