Hey! Currently, I’m working on a screenshot system. To do this, I tried to get all the objects in my screen, and put them inside of a viewportframe.
Here’s the code:
script.Parent.MouseButton1Click:Connect(
function()
local function hasProperty(object, prop)
local t = object[prop]
end
for i, v in pairs(workspace:GetDescendants()) do
local success =
pcall(
function()
hasProperty(v, "Position")
end
)
if success then
local vis = workspace.CurrentCamera:WorldToScreenPoint(v.Position)
if vis and not v:IsA("Terrain") and not v:IsA("Attachment") then
v:Clone().Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui.ViewportFrame
end
end
end
end
)
script.Parent.MouseButton1Click:Connect(
function()
local function hasProperty(object, prop)
local t = object[prop]
end
for i, v in pairs(workspace:GetChildren()) do
local success =
pcall(
function()
hasProperty(v, "Position")
end
)
if success then
local vis = workspace.CurrentCamera:WorldToScreenPoint(v.Position)
if vis then
for i, des in pairs(v:GetDescendants()) do
local success2 =
pcall(
function()
hasProperty(v, "Anchored")
end
)
if success2 then
des.Anchored = true
v:Clone().Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui.ViewportFrame.WorldModel
end
end
end
end
end
end
)