If part is not on screen it will anchor

I want to make it so that if a part is not on screen it will anchor.
Current code:

while task.wait(0.8) do
	local camera = game.Workspace.CurrentCamera
	local target = game.Workspace.Enemy
	local _, visible = camera:WorldToViewportPoint(target.Position)

	if visible then
		target.Anchored = false
	else
		target.Anchored = true
	end
end
2 Likes

What are you trying to create here? Are you are trying to create an entity that does not move when looked at?

Basically, but it only stops moving when it’s off screen

There are multiple threads similar topics, see if they can help you.
One topic similar to this can be found here

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.