How to make the front of an egg face the camera?

I am trying to make an egg hatching system where players can open eggs for pets. In order to do this, I need to ensure the egg is facing the correct direction to the camera.
I want to carry over the same orientation of these eggs to when they get positioned in front of the camera. For example, when opening this egg:

It gets positioned facing the opposite direction during the hatching animation:

I have tried to use the orientation of the egg in the game in my code to make it face the correct way however that doesnt seem to work.
This is my code on how I position the egg:
I am using a CFrameAngles value to deal with the egg orientation, this is so when the user moves their camera it doesn’t rotate a different way.

	local eggMesh = egg.PrimaryPart:Clone()
	eggMesh.Anchored = true
	eggMesh.CanCollide = false
	eggMesh.Size = eggMesh.Size/5
	local starsParticle = stars:Clone()
	starsParticle.Parent = eggMesh
	local CFrameValue ="CFrameValue")
	local CFrameAngles ="CFrameValue")
	CFrameAngles.Value = CFrame.Angles(0,0,0)
	CFrameValue.Value =,-5,-eggMesh.Size.Z*4)
	local eggConnection = runService.RenderStepped:Connect(function()
		eggMesh.CFrame = camera:GetRenderCFrame() * CFrameValue.Value * CFrameAngles.Value
	eggMesh.Parent = camera

Any help would be greatly appreciated.

1 Like

How about you try to use CFrame.lookAt

CFrame.lookAt(eggMesh.Position, workspace.CurrentCamera.CFrame.Position)

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