Trying to set position and rotation on one object?

I have the player’s model in a ViewportFrame. The camera is positioned right, but the rotation is incorrect, as seen in the picture below.

I have the position set on a CFrame since it needs to be for the camera to work, the code for the output on the picture above is:

local plr = game.Players.LocalPlayer
local plrs = game:GetService("Players")
local char = plr.Character or plr.CharacterAdded:wait()
local hum = char:WaitForChild("Humanoid")
local vf = script.Parent
local vfc = Instance.new("Camera", vf)
vf.CurrentCamera = vfc
local m = Instance.new("Model", vf)
m.Name = plr.Name
for k,v in pairs(char:GetChildren()) do
	v:Clone().Parent = m
end
vfc.CFrame = m.HumanoidRootPart.CFrame*CFrame.new(0,0,10)

But if I try to add a CFrame.Angles to it, it breaks which is reasonable. Can anyone guide me towards the answer?

I appreciate all and any help I receive.

2 Likes

I believe you should multiply

m.HumanoidRootPart.CFrame*CFrame.new(0,0,10)

with CFrame.Angles

1 Like

What exactly do you want the rotation to be? Overall, you’re pretty vague in what you’re trying to achieve. Some clarification?

1 Like

My apologies. I want to rotate the player model so the front, where the faces are displayed, is facing the camera.

1 Like

I had tried that, the camera was not acting right, it was zoomed and rotated.

1 Like

This works to set the camera in a correct position.

vfc.CFrame = m.HumanoidRootPart.CFrame*CFrame.new(0,0,-10,0,1,0,0)

This makes it look at the front of the character.

1 Like

I never knew you could add 2 CFrame values on one.

1 Like

Although, it just makes the screen white.

Works fine for me, are you getting any errors?

local plr = game.Players.LocalPlayer
local plrs = game:GetService("Players")
local char = plr.Character or plr.CharacterAdded:wait()
local hum = char:WaitForChild("Humanoid")
local vf = script.Parent
local vfc = Instance.new("Camera", vf)
vf.CurrentCamera = vfc
local m = Instance.new("Model", vf)
m.Name = plr.Name
for k,v in pairs(char:GetChildren()) do
	v:Clone().Parent = m
end
vfc.CFrame = m.HumanoidRootPart.CFrame*CFrame.new(0,0,-10,0,1,0,0)

This made it look at the character from the front.

1 Like

What do you mean by it breaks? I believe if you’re trying to rotate the entire model you would need to use model:SetPrimaryPartCFrame()

Oh nevermind, it works, not sure why it wasn’t working. Thank you sir.

By break, the camera would add onto the CFrame of the position, so it would be rotated and zoomed in more than I wanted.