so here's the code:
local ply = game.Players.LocalPlayer local gui = ply:WaitForChild('PlayerGui'):WaitForChild('ScreenGui'):WaitForChild('Inventory') local InventoryOpened = false function onKeyPress(actionName, userInputState, inputObject) if userInputState == Enum.UserInputState.Begin then print("E was pressed") if InventoryOpened == false then gui:TweenPosition(UDim2.new({0.15, 0},{0.2, 0}), "InOut", "Quad", 1, true) InventoryOpened = true else print('should close here') gui:TweenPosition(UDim2.new({0.15, 0},{1, 0}), "InOut", "Quad", 1, true) InventoryOpened = false end end end game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.E)
The 'Inventory' gui should move to {0.15, 0},{0.2, 0} but for some reason it moves to {0, 0},{0,0}. Also, the gui doesn't close when I press 'E' again.
Any help would be appreciated.
When you are doing a TweenPosition, you would not include the {} around the set values.
So Instead of
gui:TweenPosition(UDim2.new({0.15, 0},{0.2, 0}), "InOut", "Quad", 1, true)
You do
gui:TweenPosition(UDim2.new(0.15, 0,0.2, 0), "InOut", "Quad", 1, true)