I have written code so that two separate GUI from other sides to come in like cinema curtains, then go out. I put one script in the SCREENGUI next to the Frames, (the curtains). When I play only one side functions. Could anybody explain why and write the alternative answer to this? I put the code in a LocalScript.
local TransitionScreen1 = script.Parent.TransitionScreen1 local TransitionScreen2 = script.Parent.TransitionScreen2 function Transition1() TransitionScreen1:TweenPosition(UDim2.new(-0.5,0,0,0), Enum.EasingDirection.In, Enum.EasingStyle.Sine, 2, false, nil) wait(3) TransitionScreen1:TweenPosition(UDim2.new(-1, 0, 0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 2, false, nil) wait(3) TransitionScreen1.Position = UDim2.new(-1,0,0,0) end function Transition2() TransitionScreen2:TweenPosition(UDim2.new(0.5,0,0,0), Enum.EasingDirection.In, Enum.EasingStyle.Sine, 2, false, nil) wait(3) TransitionScreen2:TweenPosition(UDim2.new(1, 0, 0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 2, false, nil) wait(3) TransitionScreen2.Position = UDim2.new(1,0,0,0) end wait(2) print("test") Transition1() Transition2()
Tweening runs directly and doesn't yield, the last parameter of TweenPosition is a callback function you can pass that runs as soon as the tween is done.
Alternatively if you want it to open and close directly after one another you could use the TweenService way https://developer.roblox.com/en-us/api-reference/function/TweenService/Create.
The TweenService allows you to use TweenInfo unlike TweenPosition, the TweenInfo object actually has 2 properties that allow you to set how many times a tween repeats and if it should automatically reverse the tween after completed.