I've checked the developer log, no errors relating to this script. The tweening just doesn't play. . Anyway, I have this system to tween 2 things at once, Coroutines just didn't time correctly. so I did this in the main script:
01 | local Int = Instance.new( "IntValue" ) |
02 | Int.Parent = screen |
03 | Int.Name = "TweenTrigger" |
04 | Int.Value = 0 |
05 | local Left, Right = game.ReplicatedStorage.Left, game.ReplicatedStorage.Right |
06 | Left:Clone().Parent = screen |
07 | Right:Clone().Parent = screen |
08 | while wait() do |
09 | if Int.Value = = 2 then |
10 | Int.Value = Int.Value + 1 |
In two seperate scripts named Left and Right, for the tweening, I have this code:
01 | while wait() do |
02 | if script.Parent.Name = = "LoadGui" then break end |
03 | end |
04 | local Int = script.Parent:WaitForChild( "TweenTrigger" ).Value |
05 | local Right = script.Parent.Right |
06 | Int = Int + 1 |
07 | if Int = = 3 then |
08 | Right:TweenPosition(UDim 2. new( 1.5 , 0 , 0 , 0 ), "In" , "Sine" , 5 , false , nil ) |
09 | Right:Destroy() |
10 | script:Destroy() |
11 | end |
Any ideas as to why this wouldn't work are appreciated
If I remember correctly, the tweening function does NOT yield the script while it is running... What is happening is that the gui is immediately deleted before it finishes tweening.... You should put a wait() to fix this
1 | if Int = = 3 then |
2 | Right:TweenPosition(UDim 2. new( 1.5 , 0 , 0 , 0 ), "In" , "Sine" , 5 , false , nil ) |
3 | wait( 5 ) --Wait must be put here XD |
4 | Right:Destroy() |
5 | script:Destroy() |
6 | end |
Ok here's my new code that should work but no? The animation doesn't play nor does the script continue with the deletion of the frame and script. I'm guessing its something in the second script. Yes, these are both local scripts. If it helps, its FE aswell. I've added prints around the script, and none print. So it must be the first loop in it.
01 | local Int = Instance.new( "IntValue" ) |
02 | Int.Parent = screen |
03 | Int.Name = "TweenTrigger" |
04 | Int.Value = 0 |
05 | local Left, Right = game.ReplicatedStorage.Left, game.ReplicatedStorage.Right |
06 | Left:Clone().Parent = screen |
07 | Right:Clone().Parent = screen |
08 | while wait() do |
09 | if Int.Value = = 2 then |
10 | Int.Value = Int.Value + 1 |
11 |
12 | end |
13 | end |
14 | end |
01 | while wait() do |
02 | if script.Parent.Name = = "LoadGui" then break end |
03 | end |
04 | local Int = script.Parent:WaitForChild( "TweenTrigger" ) |
05 | local IntV = Int.Value |
06 | local Right = script.Parent.Right |
07 | IntV = IntV + 1 |
08 |
09 | Int.Changed:connect( function (Num) |
10 | if Num = = 3 then |
11 | Right:TweenPosition(UDim 2. new( 1 , 0 , 0 , 0 ), "In" , "Sine" , 5 , false , nil ) |
12 | Right:Destroy() |
13 | script:Destroy() |
14 | end |
15 | end ) |