I have two NPCs currently in my game, and my chat GUI with them includes a viewport frame that renders their model as shown:
However, my second NPC, who has a different orientation when compared to the first, does not render correctly. The NPC is facing away from the camera in this case. I tried simply changing the orientation of the clone’s hrp but it didn’t work as intended. Any help would be appreciated, thanks!
Code that worked for the first NPC but not the second:
local clone = npc:Clone()
clone.Parent = player.PlayerGui.NPCConversation.TextButton.Frame.ViewportFrame.WorldModel
clone.PrimaryPart.Position = Vector3.new(0, 0, 0)
clone.PrimaryPart.Orientation = Vector3.new(0, 0, 0)
local viewportCamera = Instance.new("Camera")
viewportCamera.Parent = player.PlayerGui.NPCConversation
viewportCamera.CFrame = CFrame.lookAt(clone.Head.Position-Vector3.new(-0.5, 0.5, 3), clone.Head.Position-Vector3.new(0, 0.5, 0))
player.PlayerGui.NPCConversation.TextButton.Frame.ViewportFrame.CurrentCamera = viewportCamera
Code I have now, expected this to work but neither of the NPCs render
local clone = npc:Clone()
clone.Parent = player.PlayerGui.NPCConversation.TextButton.Frame.ViewportFrame.WorldModel
clone.PrimaryPart.Position = Vector3.new(0, 0, 0)
local viewportCamera = Instance.new("Camera")
viewportCamera.Parent = player.PlayerGui.NPCConversation
viewportCamera.CFrame = CFrame.lookAt(clone.Head.Position-Vector3.new(-0.5, 0.5, 3), clone.Head.Position-Vector3.new(0, 0.5, 0))
clone.PrimaryPart.CFrame = CFrame.lookAt(clone.PrimaryPart.Position, viewportCamera.CFrame.Position)
player.PlayerGui.NPCConversation.TextButton.Frame.ViewportFrame.CurrentCamera = viewportCamera