I am planning on making a flashbang, and I was wondering how I would copy everything in the player’s camera into a viewportframe optimally, instead of copying everything from the workspace, would this be more optimal.
local worldPoint = v.Position
local vector, inViewport = camera:WorldToViewportPoint(worldPoint)
Problem with this, is I would have to loop through the entire workspace anyway. How would I do this?
First of all, you need to set the viewport current camera to the workspace current camera by using a local script, like this: ViewportFrame.CurrentCamera = workspace.CurrentCamera
Then, you need to duplicate everything from the workspace and put those into the viewportframe. Note: Some models, like the player character, have their archivable set to false. This means you can’t clone them. If you want to clone the player’s character, you need to copy all the children inside the model instead, not the model itself.
After that, you need to check if any parts move or rotate and if so, update the duplicated part’s position and rotation to match the real one. You also need to make sure if any parts get added or deleted and update those into the viewportframe. That’s all.
This was copied from another topic. I don’t want it to keep moving, I want it to copy for one frame and I don’t want to loop through the entirety of workspace while constructing the viewport frame