Issues while using CFrame.lookAt() and SetPrimaryPartCFrame()

Hello everyone! I am currently coding a hatching system for my game but am I currently facing an issue with CFrame.lookAt().

How my system works: Whenever someone hatchs an egg, a model is copied into game.Workspace and a script changes the CFrame of its primary part.

Current code:

[Model]:SetPrimaryPartCFrame(Workspace.EggOpeningScreen.__CLIENT_CAM.CFrame * CFrame.new(0, 0, -5))

-- __CLIENT_CAM is a part

Result:

As you can see, the pet’s face is not facing the “CLIENT_CAMERA” part. Whenever I try to use CFrame.lookAt, the pet gets a total different position for some reasons. I do not understand why.

Code:

local newCFrame = CFrame.lookAt(
	Workspace.EggOpeningScreen.__CLIENT_CAM.CFrame.Position * CFrame.new(0, 0, -5).Position,
	Workspace.EggOpeningScreen.__CLIENT_CAM.CFrame.Position
)
[Model]:SetPrimaryPartCFrame(newCFrame)
2 Likes

check the primary part in case the front isnt the front of the model
you could do something like put an attachment inside it with the position (0,0,-1), or put a decal inside the part with the front surface

1 Like

I just checked using your method, and it seems the Back of the PrimaryPart is facing the camera. I don’t know why.

try rotating the ONLY the primary part 180 degrees