Hello, i was scripting SCP-173 and i decided to use camera:WorldToViewportPoint() and it works not as intended.
local camera = workspace.CurrentCamera
local worldPoint = workspace:FindFirstChild("173").PrimaryPart.Position
while wait() do
local onScreen = camera:WorldToViewportPoint(worldPoint)
if onScreen == true then
game.ReplicatedStorage["173"]:FireServer(true)
elseif onScreen == false then
game.ReplicatedStorage["173"]:FireServer(false)
end
end
The script is a localscript. My problem is that most of the time it works perfectly fine, but sometimes when you go from behind the object it just doesn't register as onScreen and returns false. I made the part i'm detecting as big as i can and it still doesn't work, no matter what i do. Even if there's just a part i'm trying to detect on a baseplate it still works the same.

2 comments
Maybe use the LookAt() function instead | https://developer.roblox.com/en-us/api-reference/datatype/CFrame
Does it return a boolean?