Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

TweenScript Does Not Function AS iNTENEDED?

Asked by
sammiya1 134
8 years ago
1wait(1)
2while script.Parent.Position == (UDim2.new(0.25, 0,0.05, 0))
3do script.Parent:TweenPosition(UDim2.new(0.25, 0,0.06, 0))
4end
5--Now For Up--
6wait(2)
7while script.Parent:TweenPosition(UDim2.new(0.25, 0,0.06, 0))
8do script.Parent:TweenPosition(UDim2.new(0.25, 0,0.05, 0))
9end

It crashes my studio too lmao

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

Let's go through the list of problems.

  • Number One,

You're not waiting in the loop. Please look at the current tip of the day once and a while.

  • Number Two,

You have two while loops and code can't run at the same place at the same time unless you use special functions.

  • Number Three,

You're not telling your tween how long you want it to last, so it happens instantly.

Fix,

After fixing all these problems we get a script that loops somewhat like this,

1while wait() do
2    if script.Parent.Position == (UDim2.new(0.25, 0,0.05, 0)) then
3        script.Parent:TweenPosition(UDim2.new(0.25, 0,0.06, 0),"Out", "Quad", 0.02)
4    elseif script.Parent.Position == (UDim2.new(0.25, 0,0.06, 0)) then
5        script.Parent:TweenPosition(UDim2.new(0.25, 0,0.05, 0),"Out", "Quad", 0.02)
6    end
7end

However you made it move so slightly that you'll probably never notice it. So I made it move faster and further. We also really don't need conditional statement, we can just wait for the tween to stop. Example,

1while wait(0.5) do
2    script.Parent:TweenPosition(UDim2.new(0.25, 0,0.7, 0),"Out", "Quad", 0.5)
3    wait(0.5)
4    script.Parent:TweenPosition(UDim2.new(0.25, 0,0.4, 0),"Out", "Quad", 0.5)
5end

Here's a link for more about tweening.

Good Luck!

If I helped, please don't forget to accept my answer.
Ad

Answer this question