How would I go about making a mirror?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I am trying to make a viewport frame act as a mirror.

  2. What is the issue? Due to the perspective of the camera, the viewport frame acts as a screen rather than a mirror.

  3. What solutions have you tried so far? I looked around on how to horizontally flip gui objects, though it didn’t work with viewport frames. I have heard that I have to make code to mirror the objects with, but it’d be best if the solution didn’t include that, unless absolutely necessary.

I’d like to know if there’s any solutions without coding the objects to mirror themselves. And if there isn’t, I would greatly appreciate if you hinted me the right direction on how I would go about it.
image

2 Likes

Have you tried multiplying the X axis of either the camera or ViewportFrame by -1? I haven’t used ViewportFrames before but I’d think it would be that simple.

I dont really know how to do that. Could you elaborate further?

I just hopped onto Studio to test it myself, and for some reason I guess you just can’t do that with ViewportFrames (they have an Image section in the properties, but no ImageRectOffset or ImageRectSize properties?), which I think is dumb.
The closest thing you have to making a mirror here is flipping the models in the viewport via CFrame.
I find it confusing how this is an issue since 2019 and it’s still not been fixed.

Are you sure this works? I tried it, and now the farther away I am from the mirror the closer I am in the reflection. And even then, it still it doesn’t show me on the correct side. Perhaps I’m doing something wrong.

local function updateView()
	for order, part in ipairs(game.Workspace:GetDescendants()) do
		if part.Name ~= "Terrain" and (part:IsA("BasePart") and not part:IsA("Model")) then
			if part:FindFirstChild("Humanoid") then part.Archivable = true end
			local newPart = part:Clone()
			newPart.Parent = gui.ViewportFrame
			newPart.CFrame = CFrame.new(-newPart.CFrame.x, newPart.CFrame.y, newPart.CFrame.z) * (newPart.CFrame - newPart.CFrame.p)
		end
	end
end
2 Likes

I’ve gotten closer to my desired result, but now it’s off center.

local function updateView()
	for order, part in ipairs(game.Workspace:GetChildren()) do
		if part.Name ~= "Terrain" and (part:IsA("BasePart") or part:IsA("Model")) then
			--if part:FindFirstChild("Humanoid") then part.Archivable = true end
			if part == placeholder then return end
			part.Archivable = true
			local newPart = part:Clone()
			newPart.Parent = gui.ViewportFrame
			
			if part:IsA("BasePart") then newPart.CFrame = CFrame.new(newPart.CFrame.x, newPart.CFrame.y, -newPart.CFrame.z) * (newPart.CFrame - newPart.CFrame.p)
			else newPart:PivotTo(CFrame.new(newPart:GetPivot().x, newPart:GetPivot().y, -newPart:GetPivot().z) * (newPart:GetPivot() - newPart:GetPivot().p)) end
		end
	end
end