I want to achieve a server-side animation player, however it keeps saying on line 31 that attempt to index nil with play.
Here’s the script:
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local AnimationsStorage = script:WaitForChild("Animations")
local CurrentPose
local AllTracks = {}
for _,anim in pairs (AnimationsStorage:GetChildren()) do
print("Loading Animations")
AllTracks[anim.Name] = Humanoid:FindFirstChildOfClass("Animator"):LoadAnimation(anim)
AllTracks[anim.Name].KeyframeReached:Connect(function(keyname)
if Character.PrimaryPart:FindFirstChild(keyname) and Character.PrimaryPart:FindFirstChild(keyname):IsA("Sound") then
Character.PrimaryPart:FindFirstChild(keyname):Play()
end
end)
end
--//Animation Setup
function RollAnimation(animname,priority,speed)
print(animname)
for i,v in pairs (AllTracks) do
print(i,v)
end
print("Rolling Animation")
if AllTracks[CurrentPose] then
AllTracks[CurrentPose]:Stop(Humanoid.WalkSpeed/100)
end
AllTracks[animname]:Play()
AllTracks[animname]:AdjustSpeed(speed)
CurrentPose = animname
end
--//Humanoid
function OnRun(speed)
if speed > 1 then --Walking
RollAnimation("Walk",Enum.AnimationPriority.Core,(speed/Humanoid.WalkSpeed))
else
RollAnimation("IdleStanding",Enum.AnimationPriority.Idle,.3)
end
end
function OnIdled()
RollAnimation("Idle",Enum.AnimationPriority.Idle,.3)
end
function OnJump()
RollAnimation("Jump",Enum.AnimationPriority.Movement,.3)
end
function OnFall()
RollAnimation("Fall",Enum.AnimationPriority.Movement,.3)
end
function OnDied()
end
OnIdled()
Humanoid.Running:Connect(OnRun)
Humanoid.Jumping:Connect(OnJump)
Humanoid.FreeFalling:Connect(OnFall)
Humanoid.Died:Connect(OnDied)
Please help