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

AnimationTrack:AdjustSpeed(0) is not working at "all"?

Asked by 4 years ago

The meaning of the title, means my code only worked at "half".

Let me post my code first.

local Poisonous = workspace:WaitForChild("Intermission").Poisonous --boolValue
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://3616641128"

function freezeAnimationAtTime(animationTrack, timePosition) 
    wait(timePosition)
    animationTrack.TimePosition = timePosition
    animationTrack:AdjustSpeed(0)
end

Poisonous.Changed:Connect(function(Value)
    if Poisonous.Value == true then
        CurrentCamera.CameraSubject = character.Head
        freezeAnimationAtTime(humanoid:LoadAnimation(Anim),4.5)
        humanoid:LoadAnimation(Anim):Play()
    end
end)

These code works perfectly, but there's something happened.

in the single player test, when the animation played, it still not pause at 4.5 second.

in the two player test, when the animation played, it still not pause at 4.5 second. BUT

when they watch other side, they DO paused!

is there any problem in my code? how to fix it or it just glitched?

By the way, there's not all my codes. If you request more information i'll update them.

cheers.

1 answer

Log in to vote
1
Answered by
Elixcore 1337 Moderation Voter
4 years ago
Edited 4 years ago

Very simple problem, it's the fact you are calling 2 different animationtracks, instead of one.

What you should be doing is assigning the animationtrack to a variable and then using it inside of your functions.

I also recommend having the animation play and then the function because it might yield.

local Poisonous = workspace:WaitForChild("Intermission").Poisonous --boolValue
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://3616641128"

local anim = humanoid:LoadAnimation(Anim) -- create AnimationTrack

function freezeAnimationAtTime(animationTrack, timePosition) 
    wait(timePosition)
    animationTrack.TimePosition = timePosition
    animationTrack:AdjustSpeed(0)
end

Poisonous.Changed:Connect(function(Value)
    if Poisonous.Value == true then
        CurrentCamera.CameraSubject = character.Head
    anim:Play() -- use anim variable
        freezeAnimationAtTime(anim, 4.5) -- use anim variable
    end
end)
0
Question solved perfectly! Thank you a lot :D MEndermanM 73 — 4y
Ad

Answer this question