script.Parent.MouseButton1Click:Connect(function()
local openThis = script.Parent.Parent.ShopFrame
if openThis.Visible == true then
local TweeningService = game:GetService("TweenService")
local partChanges = {
Position = UDim2.new({0.3, 0},{1.5, 0})
}
local TweenInformation = TweenInfo.new(
0.2, -- Tween length
Enum.EasingStyle.Bounce, -- Easing Style
Enum.EasingDirection.In, -- Easing Direction
0, -- Repitition times
false, -- Reverse?
0 -- Delay
)
local tween = TweeningService:Create(openThis, TweenInformation, partChanges)
tween:Play()
tween.Completed:wait()
openThis.Visible = false
openThis.Position = UDim2.new({0.3, 0},{-0.8, 0})
elseif openThis.Visible == false then
openThis.Visible = true
local TweeningService = game:GetService("TweenService")
local partChanges = {
Position = UDim2.new({0.3, 0},{0.15, 0})
}
local TweenInformation = TweenInfo.new(
0.2, -- Tween length
Enum.EasingStyle.Bounce, -- Easing Style
Enum.EasingDirection.In, -- Easing Direction
0, -- Repitition times
false, -- Reverse?
0 -- Delay
)
local tween = TweeningService:Create(openThis, TweenInformation, partChanges)
tween:Play()
end
end)
That is the code in a LocalScript, the script is in another GUI button that opens "openThis". First time I click the button, the GUI appears but then tweens to the Position ({0, 0} {0, 0}). When I click the button again, the GUI just disappears without tweening. If I open the GUI again (click the button). It just appears on the same position, no matter how many times I click the button, the GUI stays on the same place.

1 comment
rather than using TweenService, you can use the tweenposition function for guis.