Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

1 comment

0

Question solved perfectly! Thank you a lot :D

This discussion is preserved as it was. New answers, comments, and votes are closed.