Hi, I’m trying to create a camera system and I use GetPartBoundsInBox to get all the parts within the area I want the camera to see (Im using a viewport frame) but I ran into a problem that I am unsure how to fix.
Whenever a player is within the area none of the accessories or head is copied into the viewport.
Is there a way to fix this?
Heres the code.
local Gui = script.Parent
local Camera = workspace.Cameras.Camera1
local ViewportCamera = Instance.new("Camera")
local Screen = Camera.Screen
local DetectZone = Camera.DetectZone
ViewportCamera.CFrame = Screen.CFrame
Gui.ViewportFrame.CurrentCamera = ViewportCamera
while true do
wait(.6)
ViewportCamera.CFrame = Screen.CFrame
local parts = workspace:GetPartBoundsInBox(DetectZone.CFrame,DetectZone.Size)
local OldParts = Gui.ViewportFrame:GetChildren()
for _, part in OldParts do
part:Destroy()
end
for _, part in parts do
local Clone = part:Clone()
Clone.Parent = Gui.ViewportFrame
end
end