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

How can I make this animation restart?

Asked by 4 years ago
Edited 4 years ago
            local anim = Instance.new("Animation")
            anim.AnimationId = "http://www.roblox.com/Asset?ID=6064117482"
            local track = p.Character.Humanoid:LoadAnimation(anim)
            if phase == 1 then
                local date = Instance.new("IntValue")
                date.Name = "BreathData"
                date.Value = DateTime.now().UnixTimestampMillis
                date.Parent = p.Data
                p.Character.Humanoid.WalkSpeed = 0
                p.Character.Humanoid.JumpPower = 0
                wait()
                track:Play()
                wait(.8)
                track:AdjustSpeed(0)
                if p.Data:WaitForChild("BreathData",.1) == nil then
                    print("1")
                    track:AdjustSpeed(1)
                    wait(.5)
                    p.Character.Humanoid.WalkSpeed = 16
                    p.Character.Humanoid.JumpPower = 50
                    local cooldown = Instance.new("BoolValue")
                    cooldown.Value = true
                    cooldown.Name = "Breath"
                    cooldown.Parent = p.Data.Cooldowns
                    wait(5)
                    cooldown:Remove()
                end
            elseif phase == 2 then
                local get = p.Data:WaitForChild("BreathData",.1)
                if get then
                    local power = DateTime.now().UnixTimestampMillis - get.Value
                    get:Remove()
                    if power > 1000 then
                        print(tostring(track))
                        print("2")
                        track:AdjustSpeed(1)
                        wait(.5)
                        p.Character.Humanoid.WalkSpeed = 16
                        p.Character.Humanoid.JumpPower = 50
                        local cooldown = Instance.new("BoolValue")
                        cooldown.Value = true
                        cooldown.Name = "Breath"
                        cooldown.Parent = p.Data.Cooldowns
                        print(tostring(power))
                        wait(5)
                        cooldown:Remove()
                    end

this is a part of my code. at phase == 2 i try to continue the animation that i paused at phase == 1.

                if p.Data:WaitForChild("BreathData",.1) == nil then
                    print("1")
                    track:AdjustSpeed(1)
                    wait(.5)
                    p.Character.Humanoid.WalkSpeed = 16
                    p.Character.Humanoid.JumpPower = 50
                    local cooldown = Instance.new("BoolValue")
                    cooldown.Value = true
                    cooldown.Name = "Breath"
                    cooldown.Parent = p.Data.Cooldowns
                    wait(5)
                    cooldown:Remove()
                end

while this part of code works without problem, i cant continue the animation at phase == 2. they are the same thing why? power isn't none and track isn't nil

Answer this question