Hello! I am trying to make a dialogue system where there is a viewport system that shows who your talking to. Everything works, but it shows you the back of their head rather than the front.
I can’t seem to find out how to change its orientation. Here is the script:
local function setupViewportFrame(characterModel)
characterViewport:ClearAllChildren()
local viewportCamera = Instance.new("Camera")
viewportCamera.Parent = characterViewport
characterViewport.CurrentCamera = viewportCamera
local characterClone = characterModel:Clone()
characterClone.Parent = characterViewport
local primaryPart = characterClone.PrimaryPart or characterClone:FindFirstChild("HumanoidRootPart") or characterClone:FindFirstChild("Torso") or characterClone:FindFirstChild("UpperTorso")
if primaryPart then
characterClone:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0, 0, 0)))
local cameraPosition = primaryPart.Position + primaryPart.CFrame.LookVector * -3 + Vector3.new(0, 1, 0) -- Adjust as needed
viewportCamera.CFrame = CFrame.new(cameraPosition, primaryPart.Position + Vector3.new(0, 1, 0)) -- Look at the character's head area
for _, descendant in pairs(characterClone:GetDescendants()) do
if descendant:IsA("Decal") or descendant:IsA("Texture") then
descendant.Parent = descendant.Parent
end
end
else
warn("No PrimaryPart found for character model:", characterModel.Name)
end
end
How would I go about changing its rotation so that it shows the front of the character?
Any help is appreciated!