Currently having problems with animating characters in ViewportFrames. Here is the code:
local currentChar = Player.Stats.EquippedCharacter.Value
local Char = MakeCharacter(currentChar)
Char.Parent = newVP.WorldModel
if Module.Animations and Module.Animations.Idle then
local anim = Instance.new("Animation") do
anim.AnimationId = Module.Animations.Idle
print(Char, Char.Humanoid)
print(Char.Parent)
end
local track = Char.Humanoid:LoadAnimation(anim)
track.Looped = true
track:Play()
end
The output would give me this error everytime
Even though the character exists, and is in the WorldModel, it’s acting as if it isnt? Any help would be appreciated.
You can’t use animations on ViewportFrames, per the wiki.
Instead, try setting the part CFrame to the animations. This may be extremely performance intensive, so please be aware of what you use this for.
Fixed it! I set up the animation before parenting the Viewportframe!
local currentChar = Player.Stats.EquippedCharacter.Value
local Char = MakeCharacter(currentChar)
Char.Parent = newVP.WorldModel
newVP.Parent = Frame
if Module.Animations and Module.Animations.Idle then
local anim = Instance.new("Animation") do
anim.AnimationId = Module.Animations.Idle
print(Char, Char.Humanoid)
print(Char.Parent)
end
local track = Char.Humanoid:LoadAnimation(anim)
track.Looped = true
track:Play()
end
@ViserLizz Roblox recently introduced WorldModel which allows you to replicated physics and perform raycasts in ViewportFrames