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

Tweening animations wont play?

Asked by
H4X0MSYT 536 Moderation Voter
8 years ago

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:

local Int = Instance.new("IntValue")
    Int.Parent = screen
    Int.Name = "TweenTrigger"
    Int.Value = 0
    local Left, Right = game.ReplicatedStorage.Left, game.ReplicatedStorage.Right
    Left:Clone().Parent = screen
    Right:Clone().Parent = screen
    while wait() do
        if Int.Value == 2 then
            Int.Value = Int.Value + 1

In two seperate scripts named Left and Right, for the tweening, I have this code:

while wait() do
    if script.Parent.Name == "LoadGui" then break end
end
local Int = script.Parent:WaitForChild("TweenTrigger").Value
local Right = script.Parent.Right
Int = Int + 1
if Int == 3 then
    Right:TweenPosition(UDim2.new(1.5, 0, 0, 0), "In", "Sine", 5, false, nil)
    Right:Destroy()
    script:Destroy()
end

Any ideas as to why this wouldn't work are appreciated

2 answers

Log in to vote
0
Answered by 8 years ago

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

if Int == 3 then
    Right:TweenPosition(UDim2.new(1.5, 0, 0, 0), "In", "Sine", 5, false, nil)
    wait(5) --Wait must be put here XD
    Right:Destroy()
    script:Destroy()
end
0
use local tween = Right:TweenPosition(UDim2.new(1.5, 0, 0, 0), "In", "Sine", 5, false, nil), repeat wait() until tween.TweenStatus == Enum.TweenStatus.Completed (Wiki it though, not sure what the actual value is called) RubenKan 3615 — 8y
0
What about the repeat until? Unless right and left are created at the exact same time.. H4X0MSYT 536 — 8y
0
It still doesn't play.. No errors H4X0MSYT 536 — 8y
Ad
Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
8 years ago
Edited 8 years ago

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.

    local Int = Instance.new("IntValue")
    Int.Parent = screen
    Int.Name = "TweenTrigger"
    Int.Value = 0
    local Left, Right = game.ReplicatedStorage.Left, game.ReplicatedStorage.Right
    Left:Clone().Parent = screen
    Right:Clone().Parent = screen
    while wait() do
        if Int.Value == 2 then
            Int.Value = Int.Value + 1

        end
    end 
end
while wait() do
    if script.Parent.Name == "LoadGui" then break end
end
local Int = script.Parent:WaitForChild("TweenTrigger")
local IntV = Int.Value
local Right = script.Parent.Right
IntV = IntV + 1

Int.Changed:connect(function(Num)
    if Num == 3 then
        Right:TweenPosition(UDim2.new(1, 0, 0, 0), "In", "Sine", 5, false, nil)
        Right:Destroy()
        script:Destroy()
    end
end)

Answer this question