It's because it's setting the Visible property to false before the tween completes, I think you tought the script pauses during the tween, but no, it doesn't. To fix it, we can use the callback argument in the TweenPosition function. Here is an example of how you need to do it:
1 | chosen.PlayerGui.Picker.Background:TweenPosition(UDim 2. new(number x, number y, number z), "Out" , "Sine" , 1 , true ,functiontorunwhentweencompletes) |
Here is an explaining: the first argument is the position to tween to (in the Udim2.new function). Then, we need to put the next arguments outside of the parenthesis of the Udim2.new function, wich are: easingDirection(in this case, "Out"), easingStyle(in this case, "Sine"), time(seconds for it to complete, should not be a number <0), override(true if you want it to override other tweens, false if you don't), and callback, wich, if you have a set up function, you can enter it there so it runs after the tween is completed, wich we can use to set the Visible property to false. So your script can look like that:
1 | local function setVisibility() |
2 | chosen.PlayerGui.Picker.BackGround.Visible = false |
4 | chosen.PlayerGui.Picker.Background:TweenPosition(UDim 2. new( 0.4 , 0 , 0.25 , 0 ), "set your easingDirection" , "setyoureasingStyle" ,seconds for the tweeen to complete) |
6 | chosen.PlayerGui.Picker.Background:TweenPosition(UDim 2. new( 0.4 , 0 , 0.25 , 0 ), "set your easingDirection" , "setyoureasingStyle" ,seconds for the tweeen to complete,setVisibility) |
Hereis a wiki link for the easing direction and styles:
https://developer.roblox.com/en-us/articles/GUI-Animations
(Click Additional Options in the top right corner)