Im trying to play this animation of a viewmodel with a humanoid and an animator.
The animation just doesnt play for sum reason
Heres the code
-- Load the walking animation
local replicatedStorage = game:GetService("ReplicatedStorage")
local viewModel = replicatedStorage:WaitForChild("ViewModel")
print("ViewModel found")
-- Ensure the viewmodel has a Humanoid
local humanoid = viewModel:FindFirstChild("Humanoid")
if not humanoid then
print("No Humanoid found in ViewModel")
return
end
print("Humanoid found in ViewModel")
-- Ensure the Humanoid has an Animator
local animator = humanoid:FindFirstChildOfClass("Animator")
if not animator then
animator = Instance.new("Animator")
animator.Parent = humanoid
print("Animator added to Humanoid")
else
print("Animator already exists in Humanoid")
end
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://133960319686107"
local animationTrack = animator:LoadAnimation(animation)
print("Animation loaded")
humanoid.Running:Connect(function(speed)
print("Running event triggered with speed:", speed)
if speed > 0 then
if not animationTrack.IsPlaying then
animationTrack:Play()
print("Animation playing")
end
else
if animationTrack.IsPlaying then
animationTrack:Stop()
print("Animation stopped")
end
end
end)
animationTrack.Stopped:Connect(function()
print("Animation track stopped")
end)
Output when starting the game:
So everything is loading and the script knows it exists but it still doesnt play.
Output when walking is nothing.