I’m creating a minimap and am trying to set the minimap to always appear on the top right corner of the game.
My minimap is done by attaching a surface gui to a workspace part and having a viewport frame within the surface gui.
I’m currently trying to set the Cframe of this workspace part such that it appears on the top right corner.
--position of the minimap on player's screen
minimap:SetPrimaryPartCFrame(game.Workspace.CurrentCamera.CFrame*CFrame.Angles(math.rad(90), 0, 0)*CFrame.new(10,-10,-3))
However, this method is not responsive to screen size. When my screen is wide, the position of the minimap is as such:
Any reasons why you are using a surface gui with a workspace part? Are you looking to make a 3d map like effect? If not then a ScreenGui like in the Frames | Roblox Creator Documentation tutorial should be suitable enough for 2d maps.
If so then to make it relative to screen size you will definitely to make the part relative to a Udim2 as Udim2’s scale with screen size automatically. I believe you can create a GUI Frame | Roblox Creator Documentation for this, set the Udim2 to position on the screen the usual way, then work with the GuiBase2d | Roblox Creator Documentation property and position properties somehow, I’m not too experienced with this unfortunately.
I had to do something similar as this for a game and I forgot what was the exact cframe code but it was basically ToObjectSpace but on a low level (iirc it was like)