I was created a Camera taking picture with Viewport but this not taking Player Models into viewport
This is script
local gui = script.Parent
local viewportFrame = gui:WaitForChild("ViewportFrame")
local viewportCamera = Instance.new("Camera")
viewportCamera.FieldOfView = 70
viewportFrame.CurrentCamera = viewportCamera
local cameraPart = gui.Adornee.Parent:WaitForChild("Camera")
local detectZone = gui.Adornee.Parent:WaitForChild("DetectZone")
local prompt = detectZone:WaitForChild("ProximityPrompt")
local debounce = false
prompt.Triggered:Connect(function()
if debounce then return end
debounce = true
prompt.Enabled = false
viewportFrame:ClearAllChildren()
local sceneModel = Instance.new("Model")
sceneModel.Name = "ViewportScene"
sceneModel.Parent = viewportFrame
viewportCamera.CFrame = cameraPart.CFrame * CFrame.new(0, 3, -8)
local lightPart = Instance.new("Part")
lightPart.Anchored = true
lightPart.CanCollide = false
lightPart.Transparency = 1
lightPart.Size = Vector3.new(1, 1, 1)
lightPart.CFrame = cameraPart.CFrame
local light = Instance.new("PointLight")
light.Brightness = 4
light.Range = 60
light.Color = Color3.fromRGB(255, 255, 200)
light.Parent = lightPart
lightPart.Parent = sceneModel
for _, obj in ipairs(workspace:GetChildren()) do
local isValid =
not obj:IsA("Terrain") and
obj ~= cameraPart and
obj ~= detectZone and
obj.Name ~= "Players"
if isValid then
local success, clone = pcall(function()
return obj:Clone()
end)
if success and clone then
for _, part in ipairs(clone:GetDescendants()) do
if part:IsA("BasePart") then
part.Anchored = true
part.CanCollide = false
end
end
if clone:IsA("Model") then
clone:MakeJoints()
end
clone.Parent = sceneModel
end
end
end
task.wait(3)
prompt.Enabled = true
debounce = false
end)
This taking eversingle thing in Workspace without Player Model.
I can’t figure out what is problem.