im making a screen shot system using viewport frames but the problem comes when i clone the whole game into one viewport frames,how can i NOT do that and only clone items that are seen by the camera?
here is my current local script
local ignore = {"Camera","Terrain","Script","LocalScript","Attachment","BodyVelocity","BodyForce","BodyThrust","SpringConstraint","Motor6d","PrismaticConstraint"}
script.Parent.MouseButton1Click:Connect(function()
local s = script.Sky:Clone()
s.Parent = script.Parent.Parent.Frame
local vpf = s.ViewportFrame
local cam = Instance.new("Camera")
cam.CFrame = workspace.CurrentCamera.CFrame
cam.Parent = vpf
vpf.CurrentCamera = cam
local scene = Instance.new("Model")
scene.Name = "Scene"
scene.Parent = vpf
for i,v in pairs(workspace:GetDescendants()) do
if (v:IsA("Part") or v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("UnionOperation")) and v.Name ~= game.Players.LocalPlayer.Name then
if not table.find(ignore,v.ClassName) then
v:Clone().Parent = scene
end
end
if v.Name == game.Players.LocalPlayer.Name then
local model = Instance.new("Model")
model.Name = v.Name
model.Parent = vpf
for i,v in pairs(v:GetChildren()) do
v:Clone().Parent = model
end
model:FindFirstChild("Humanoid").DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
end
end
end)
thx for any help you can give!