I have been working on the inventory GUI for my game and wanted to tween it so it opens smoothly. Tweening the inventory open and closed works fine, except when the inventory is closed, it is still there as a really small line.
Here is a video:
In the video, I open the inventory, where it tweens open just fine, but when I close it, the tween works, but there is a line in the centre of the screen.
Code for opening the inventory:
local openButton = script.Parent local inGameGui = openButton.Parent.Parent local frame = inGameGui.Inventory openButton.Activated:Connect(function() for i, v in pairs(inGameGui:GetChildren()) do --Hide all gui objects that are not this frame. if v ~= frame then v.Visible = false end end frame.Visible = true frame:TweenSize( UDim2.new(1.6, 0, 0.8, 0), "In", "Linear", 0.1 ) end)
Code for closing the inventory:
local closeButton = script.Parent local frame = closeButton.Parent local inGameGui = frame.Parent closeButton.Activated:Connect(function() frame:TweenSize( UDim2.new(0, 0, 0.8, 0), "In", "Linear", 0.1 ) wait(0.1) frame.Visible = false for i, v in pairs(inGameGui:GetChildren()) do --Show all gui objects that are not this frame. if v ~= frame then v.Visible = true end end end)
I have checked that visible is set to false after the inventory is tweened closed, so I am unsure of why the inventory is still present when it should be scaled to 0 on the X axis and invisible.
If you have any suggestions, please leave a reply!