WorldToScreenPoint Not Working As Intended

So I’m trying to make a scope, I’m using a viewport to make the scope effect but I’m having problems with WorldToScreenPoint. Basically the viewport needs to follow this part:

image

The Code:

game:GetService("RunService").Heartbeat:Connect(function()
	
	local vector, within = WorldToScreenPoint(workspace.CurrentCamera, ScreenPart.Position)
	
	if within then
		script.Parent.Parent.Position = UDim2.new(0, vector.X, 0, vector.Y)
	end
	
	destroyIntr(script.Parent.Interactables)
	renderObj(game.Workspace.Map.Interactables, true)
end)

Instead I get this: https://gyazo.com/bf3c5d5428d07628945e9fcd95de4017

I searched on the forum, really found nothing.

Any help would be greatly appreciated!

What is WorldToScreenPoint? Do you mean

local vector, within = workspace.CurrentCamera:WorldToScreenPoint(ScreenPart.Position)

?

(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)

That dosen’t really change anything.

https://gyazo.com/29a1735436b74a0f46869d79568220df

Stop going around posts saying Heartbeat is deprecated. For the second time, it is not, the developer portal is wrong.

The new events do not fire yet. They are not ready for production games and will break your logic.

3 Likes