How to get CFrame rotation to start by facing forward

Ok, so I have been stuck on this bug for a while now, and I was wondering if anyone had any insights.

RunService.RenderStepped:Connect(function()
	petModel:SetCFrame(CFrame.Angles(0,tick() * 2 % (math.pi * 2),0) * CFrame.Angles(math.rad(-10),0,0))
end)

Rotating wise, this works perfectly. But sometimes, instaed of the model starting by facing forward, it might be facing the side or backwards. I believe this is because of tick(), but I don’t know how to fix it.

Thank you for the help!
Koodsu

by facing forward im assuming you mean in the positive Z direction?

if so i would set the CF before the RenderStepped function.

local modelCF = model:GetPrimaryPartCFrame()

local newCF = CFrame.lookAt(modelCF.Position, modelCF.Position + Vector3.new(0,0,1))

model:SetPrimaryPartCFrame(newCF )

Can i ask what you’re trying to do? because you are right in suspecting your issue is with using tick(). Theres a much cleaner way to turn using the dt value passed every time RenderStepped fires

local 
RunService.RenderStepped:Connect(function(dt)
    petModel:SetCFrame( petModel:GetCFrame() * CFrame.Angles(math.rad(-10) * dt,0,0))

Sorry for the late response, I was getting ready for bed since its like 1:15 am, but youre second resonse was what I needed except in the original example there was a slight tilt down(image 1) vs none(image 2) in yours. I have barely any CFrame experience lol so I don’t know what to do or what is going on.
image
image

could you show me the updated code?

--------Edit--------

nvm i misread your post. gimme a sec i got u.

RunService.RenderStepped:Connect(function(dt)
		petModel:SetCFrame(petModel:GetCFrame() * CFrame.Angles(0,-3 * math.rad(-10) * dt,0))
end)

change this line of code

local newCF = CFrame.lookAt(modelCF.Position, modelCF.Position + Vector3.new(0,-.5,1), Vector3.new(0,1,0))

Not sure if thisll work lol but lmk

I never put that code in, I just used your second response.

ok ok then how bout this…

add this line under the SetCFrame line

petModel:SetCFrame( CFrame.lookAt( perModel:GetCFrame.Position, perModel:GetCFrame.Position + Vector3.new(0,.5,0)))
RunService.RenderStepped:Connect(function(dt)
		petModel:SetCFrame(petModel:GetCFrame() * CFrame.Angles(0,-3 * math.rad(-10) * dt,0))
		petModel:SetCFrame( CFrame.lookAt(petModel:GetCFrame().Position,petModel:GetCFrame().Position + Vector3.new(0,.5,0)))
end)

Nope, this just makes me see the pets footers
image

sorry change the Vector3 to this Vector3.new(0, -.5, 1)

you might want to play around with the .5 value. The greater it is that 0 the farther up it will look and the lower it is than 0 the lower it looks.

i thnk its backwards, i cant tell what direction it is lol
image

lol ok this should be last edit. Change that same vector3 to Vector3.new(0, -.5, -1)

Forgot to say this in earlierresponses, but since that last line was added, it stopped rotating

yeah i just thought about that happening. EASY FIX THOUGH

just a few lines that need to get added. heres the updated function

local currCF
local slightlyUpVector
RunService.RenderStepped:Connect(function(dt)
    currCF = petModel:GetCFrame()
    slightlyUpVector = (-currCF.LookVector + (currCF.UpVector * -.5)).Unit
    petModel:SetCFrame(currCF  * CFrame.Angles(0,-3 * math.rad(-10) * dt,0))
    petModel:SetCFrame( CFrame.lookAt(currCF.Position, currCF.Position + slightlyUpVector, Vector3.new(0,1,0) ))
end)

----edit----
missed a negative infront of currCF.LookVector

that made it bug out and jiggle up and down frame by frame

ok give me a minute or two to make sure this next edit works. Ill be back with something that works.

yo im sorry but its almost 2am for me and im a HS kid with a summer school test bright and early tmrw so i need to go to bed, I really appriciat the help tho!

local currCF
local slightlyUpVector
runSrvc.Heartbeat:Connect(function(dt)
	currCF = petModel:GetCFrame()
	currCF = CFrame.lookAt(currCF.Position, currCF.Position + (currCF.LookVector * Vector3.new(1,0,1)), Vector3.new(0,1,0))
	currCF = currCF  * CFrame.Angles(0,-3 * math.rad(-10) * dt,0)
	slightlyUpVector = (currCF.LookVector + (currCF.UpVector * -.5)).Unit
	petModel:SetCFrame( CFrame.lookAt(currCF.Position, currCF.Position + slightlyUpVector, Vector3.new(0,1,0) ))
end)

again, the -0.5 value is the one you fiddle with to adjust how high or low the pet will be looking

Sorry, I was not notified of your response and forgot about it, but I did not describe my issue correctly, here is a video to show what happens