You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Want to have consistent animation track playing along with a consistent keyframe.
I am aware of keyframereached function, but this still creates the same exact issue with timing. -
What is the issue? Include screenshots / videos if possible!
Animation issues - YouTube -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
-
Preloading
-
The keyframes are consistent enough, but the core issue is that the animation is not playing properly the first time as shown in the video. You can see the keyframe lengths are about the same.
-
Animation priority set to action!
Here is the important part of the code.
Tool.Unequipped:Connect(function()
if loaded == true then
if Shield then
Shield:Destroy()
Shield = nil
end
if EquipTrack then
EquipTrack:Stop()
EquipTrack = nil
end
if char.Humanoid.WalkSpeed <= 13 then
char.Humanoid.WalkSpeed = 16
end
end
end)
Tool.Equipped:Connect(function()
if loaded == true then
if Tool.Parent and Tool.Parent.ClassName == "Model" and Tool.Parent:FindFirstChild("WeldFolder")
and Tool.Parent:FindFirstChild("HumanoidRootPart") and Tool.Parent:FindFirstChild("Left Arm") then
char = Tool.Parent
if not Shield then
CreateShield(char)
end
EquipTrack = char.Humanoid:LoadAnimation(Animations.Equip)
local OldEquipTrack = EquipTrack
local Speed = 1
local Length = EquipTrack.Length
local keyframe = EquipTrack:GetTimeOfKeyframe("Hold")
EquipTrack:Play(0.100000001,1,Speed)
local t = tick()
wait(keyframe/Speed)
print("Keyframe length: ",tick()-t)
if Tool.Parent == char and OldEquipTrack == EquipTrack then
EquipTrack:AdjustSpeed(0) -- stops animation
end
end
end
end)