Need help with worldtoscreenpoint

Hi. I have a UI which I want to follow the character’s humanoidrootpart, however, it does not seem to be doing what I intended for it.

https://gyazo.com/db08d4b1deab4b5ba4e0955599826aff

While it still moves, it is not following the character for some reason. Here is my code:

   self.infoPanelUpdate = coroutine.create(
        function()
            while true do
                RunService.RenderStepped:Wait()
                local character = self.Player.Character
                if not character or not character.HumanoidRootPart then return end

                local screenPosition = currentCamera:WorldToScreenPoint(character.HumanoidRootPart.Position)
                local newPosition = UDim2.new(0, screenPosition.X, 0, screenPosition.Y)
                infoPanel.Position = newPosition

            end
        end
    )

    coroutine.resume(self.infoPanelUpdate)

Why don’t you use BillboardGui? It is a lot easier.

That is true, but that wouldn’t be ideal due to how I’ve set up my project.

What’s your CameraType? It looks like you’re using custom camera scripts, which means you should use the Scriptable type.

The camera type was already set to scriptable.

I just used your code and did not get any issues

This means that, if your camera is definitely scriptable, the issue is because your camera is updated too late (after the GUI updates) which makes it seem like it is falling behind.

Modularize your code and make sure that the camera update happens first and then manually call the GUI update after the camera.

1 Like