Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can anyone help me about Camera:WorldToScreenPoint() and give a better explanation for it?

I am trying to make an scp game and I am trying to make scp 173, so when you are not looking at it, it does a line of code, but when I try to use the function in the question, it would always say that it is in the screen, even when i'm not looking at it. Any help?

local Camera = game.Workspace.CurrentCamera

local Vector, InScreen = Camera:WorldToScreenPoint(workspace.Part.Position)

if InScreen then
	print("aa")
end

I just made this code, so just say the scp is the part.

2 comments

0

CAn you show us the code

0

sure!

1 answer

Like the function is named it provides the location on your screen where the object is shown and if it is seen too.

But your script is only checking once if it is in view once. To fix this we can use a loop.

local Camera = game.Workspace.CurrentCamera

while true do
	local Vector, InScreen = Camera:WorldToScreenPoint(workspace.Part.Position)

	if InScreen then
 	   print("aa")
	end
	
	wait(3) --also make sure a loop has a wait if it will run forever
end

5 comments

0

I already tried that; It would just keep printing aa.

0

@Microsoft_Net post a gif of it in action

0

ok

0
0

@Microsoft_Net make it print(Vector) and write it here (cant do it my self at school)

This discussion is preserved as it was. New answers, comments, and votes are closed.