Unknown error in Animate script from Character in ViewportFrame

I have a local script in order to show the animated face of the player in a UI.
avatar is the ViewportFrame instance, WorldModel is a child of avatar. So I put the character model under WorldModel then I create a new Instance of Camera parented to avatar. The script will work in Studio however if I join the published game a strange error occur in Animate default script inside the character.

-- [...]
local function SetAnimatedAvatar()
	local characterModel = playersService:CreateHumanoidModelFromUserId(localPlayer.UserId)
	characterModel.Parent = avatar.WorldModel
	local camera = Instance.new("Camera", avatar)
	avatar.CurrentCamera = camera
	avatar.CurrentCamera.CFrame = CFrame.new(characterModel.Head.Position - Vector3.new(0, 0, 3)) * CFrame.Angles(0, math.rad(180), 0)
end
-- [...]

Avoid using CreateHumanoidModelFromUserId. Use this function instead:

local function CloneCharacter()
	local character = game:GetService("Workspace"):WaitForChild(localPlayer.Name)
	character.Archivable = true
	local cloneCharacter = character:Clone()
	character.Archivable = false
	return cloneCharacter
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.