I don't understand AnchorPoint or Position well enough to figure out how to get a GUI to remain in a constant relative position despite my screen size. I am trying to make an inventory GUI that tweens out from the left edge of the screen (meaning most of it shouldn't be visible when its not opened); however, when I stretch my window to a different size, the part of the GUI that should be hidden beyond the left edge becomes visible. How would I go about fixing this? Here is my code if that means anything:
local TweenService = game:GetService("TweenService")
local inventory = script.Parent.Parent
function onClicked(GUI)
local openGoal = {}
openGoal.Position = UDim2.new(0.02, 0, .5, 0)
local closeGoal = {}
closeGoal.Position = UDim2.new(-0.1, 0, .5, 0)
local tweenInfo = TweenInfo.new(2)
local openInventory = TweenService:Create(inventory, tweenInfo, openGoal)
local closeInventory = TweenService:Create(inventory, tweenInfo, closeGoal)
local curr_pos = inventory.Position
if curr_pos.X.Scale <= -.09 then
openInventory:Play()
else if curr_pos.X.Scale >= 0.019 then
closeInventory:Play()
end
end
end
script.Parent.MouseButton1Click:connect(onClicked)

3 comments
AnchorPoint should be set to 0.5, 0.5 (most of the time). To get the gui to stay the same Size no matter the screen size set Size to be something like {0.2, 0},{0.2, 0}. The same thing goes for Position.
The Position should be something like {1, 0},{0.5, 0} (assuming your gui comes out from the right if its left then {0, 0},{0.5, 0} )
So, I have a Frame inside of the frame being moved. Is that causiing a problem? I've made the main frame (the one that is moving, have all the stuff you said).