Hey everyone! I am working on a game, and my animation is not working. I am doing this animation on the server because I want everyone to see the player doing the animation. I am not sure if that is right. I do not want the player to move during the animation, so I am anchoring their HumanoidRootPart. Maybe that is the reason, not sure. As you can tell, I am not that experienced with animations. Anyways, here is my script:
local humanoid = player.Character:WaitForChild("Humanoid")
local humanoidRootPart = player.Character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
humanoidRootPart.CFrame = game.Workspace:WaitForChild("MakeTable").CFrame
humanoidRootPart.Anchored = true
local anim = RS:WaitForChild("BrewAnimation")
local animator = humanoid:WaitForChild("Animator")
local trackAnim = animator:LoadAnimation(anim)
trackAnim:Play()
task.wait(5)
trackAnim:Stop()
humanoidRootPart.Anchored = false
If you know what I can change to make this animation work, please let me know! Thank you all!!!
that’s deprecated, don’t do it like that
what you did originally was right to load the animation, use Humanoid.Animator:LoadAnimation() to load the animation
Ok, so I am not the best at debugging, but I added these prints:
craftPotionEvent.OnServerEvent:Connect(function(player, potionName, potionColor)
local humanoid = player.Character:WaitForChild("Humanoid")
local humanoidRootPart = player.Character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
print("HumanoidRootPart found")
humanoidRootPart.CFrame = workspace:WaitForChild("MakeTable").CFrame
humanoidRootPart.Anchored = true
local anim = RS:WaitForChild("BrewAnimation")
if anim then
print("Animation found")
end
local animator = humanoid:WaitForChild("Animator")
if animator then
print("Animator found")
end
local trackAnim = humanoid.Animator:LoadAnimation(anim)
trackAnim:Play()
print("anim playing")
task.wait(5)
trackAnim:Stop()
humanoidRootPart.Anchored = false
local backpack = player:WaitForChild("Backpack")
local potionToClone = finalPotionModels:FindFirstChild(potionName):Clone()
potionToClone.Beaker.Color.Color = potionColor
potionToClone.Parent = backpack
end
end)
After this I tested it and this is what the output looked like:
10:51:06.969 HumanoidRootPart found - Server - IngredientsGiver:31
10:51:06.970 Animation found - Server - IngredientsGiver:37
10:51:06.971 Animator found - Server - IngredientsGiver:43
10:51:06.971 anim playing - Server - IngredientsGiver:50