I want my gui to move to the middle then to right side of the screen then it disappear but it only moves to the middle wait 5 second and disappear but I want it to move to the middle wait 5 seconds and then move to the right side here's my script (this is for my murder type game)
Script
chosen.PlayerGui.Picker.Background.Position = UDim2.new(0.1, 0, 0.25, 0) chosen.PlayerGui.Picker.Background:TweenPosition(UDim2.new(0.4, 0, 0.25, 0)) wait(5) chosen.PlayerGui.Picker.Background:TweenPosition(UDim2.new(0.4, 0, 0.25, 0)) chosen.PlayerGui.Picker.Background.Visible = false
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:
chosen.PlayerGui.Picker.Background:TweenPosition(UDim2.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:
local function setVisibility() chosen.PlayerGui.Picker.BackGround.Visible = false end chosen.PlayerGui.Picker.Background:TweenPosition(UDim2.new(0.4, 0, 0.25, 0), "set your easingDirection", "setyoureasingStyle",seconds for the tweeen to complete) wait(5) chosen.PlayerGui.Picker.Background:TweenPosition(UDim2.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)