So, I’ve been working with Viewmodels lately and the final task was to play the same animations as your Character
. Unfortunately, this has not been added in as I constantly run into the same issue. The Animation
doesn’t play as it the weight
has been set to 0; as highlighted by this bug report you cannot play an Animation when the weight
is set to 0. Here’s my code:
local function LoadAnimation(AnimationID)
local Animation = Instance.new("Animation", Viewmodel)
local NewString = string.gsub(AnimationID, "rbxassetid://", "")
if AnimationID == NewString then
NewString = string.gsub(AnimationID, "http://www.roblox.com/asset/?id=", "")
end
Animation.AnimationId = "rbxassetid://"..NewString
return Animation
end
Animator.AnimationPlayed:Connect(function(AnimationTrack)
local Animation = LoadAnimation(AnimationTrack.Animation.AnimationId)
local Track = ViewmodelAnimator:LoadAnimation(Animation)
Track:AdjustWeight(10)
wait()
print(Track.WeightCurrent)
Track:Play(0.1, 7)
Track.Stopped:Wait()
Track:Stop()
Animation:Destroy()
end)
The output being:
09:14:41.108 ▶ 0 (x213) - Client - Viewmodel:17
Any ideas why this is happening? And how to fix this?