help! my local script wouldnt play the animation in the viewmodel even though its outputting the text that i created
local animationwalk = script:WaitForChild("walk")
local arm = game.ReplicatedStorage.viewmodel.RightArm
local viewhuman = game.ReplicatedStorage.viewmodel.Humanoid
local realhuman = script.Parent:WaitForChild("Humanoid")
local RunService = game:GetService("RunService")
local walking = viewhuman:LoadAnimation(animationwalk)
print("Walking Animation Loaded:", walking)
realhuman.Running:Connect(function(movementSpeed)
print("Movement Speed:", movementSpeed)
if movementSpeed > 0 then
if not walking.IsPlaying then
print("Starting Walking Animation")
walking:Play()
end
else
if walking.IsPlaying then
print("Stopping Walking Animation")
walking:Stop()
end
end
end)
for i = 1, 5 do
print(i)
wait(0.5)
if i == 5 then
print("horray!")
end
end
it outputs but not playing the animations for the viewmodel
I’d use an Animator class for your view-model, reasoning for doing so is explained here. Just pop it under your view-model’s Humanoid and load animations using that instead.
Check and make sure only one part in your view-model is anchored, such as the Head or HumanoidRootPart.
Even if I played the animation using animator instead, it’s still not working
(iam an absolute beginner in developing btw so im sorry if im not smart, im 4 months in dev of my first game) but I’m going to give you some info about the like, thing
The ViewModel is a mesh part that maybe the problem but I’m not sure about that.
The Animation is in R6 and the humanoid of the ViewModel is R6 so It’s compatible but again it maybe because the viewmodel is an mesh part
local animationwalk = game.ReplicatedStorage.viewmodel.walk
local viewhuman = game.ReplicatedStorage.viewmodel.Humanoid.Animator
local realhuman = script.Parent:WaitForChild("Humanoid")
local RunService = game:GetService("RunService")
local walking = viewhuman:LoadAnimation(animationwalk)
print("Walking Animation Loaded:", walking)
-- Connect to the Running event of the player's Humanoid
realhuman.Running:Connect(function(movementSpeed)
print("Movement Speed:", movementSpeed)
-- Check if the player is moving
if movementSpeed > 0 then
-- Check if the animation is not already playing
if not walking.IsPlaying then
print("Starting Walking Animation")
walking:Play()
end
else
-- Check if the animation is currently playing
if walking.IsPlaying then
print("Stopping Walking Animation")
walking:Stop()
end
end
end)
-- A loop to demonstrate the script is running
for i = 1, 5 do
print(i)
wait(0.5)
if i == 5 then
print("hooray!")
end
end
i forgot to also include this but anyways i updated the viewmodel but it still wouldnt work so yeah
I finally fixed my bug, i look into it and some script is the culprit, thank you hapun for pointing out the animator thing, though its not the problem, the blog post is very informational so thank you.