Rotating Faster if I look up

I have a script that rotates the camera based on the vehicle the player is standing in. It works for the most part, but I’ve noticed that based on how up or down you are looking, the faster you spin, meaning the player’s orientation becomes desynced with the vehicle.

I’ve tried rotating based on world space but it doesn’t seem to work(CFrames are not my strength lol)

This is the code in the video, simplified to show the problem:

local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera
runService.Heartbeat:Connect(function(dt)
	camera.CFrame = camera.CFrame:ToWorldSpace(CFrame.Angles(0,dt,0)) 
end)

Sorry the video is in low framerate, it’s the best I can get.
https://i.gyazo.com/5db8da3f71594a93fda1337aab694d88.gif

Don’t know if this is wrong, but in games like Minecraft, when the player looks up there is a drastic increase in frame rate. Considering RunService.Heartbeat is frame relative, that might be what is happening

This reply is entirely correct

In this case I feel like resorting to

while true do
    -- code here
    task.wait(1)
end

is best

dt is relative to the frame rate, so even if the frame drops, it would rotate with the same rate.

i’m no math professor, but i guess the rotation looks sped up because they’re seeing something that’s close to the rotating axis.

I don’t think delta time is the reason it’s speeding up, but rather how often the connection is being fired. The Roblox docs say that if a player’s frame rate is 40 FPS, Runservice Heartbeat will fire 40 times per second. When the player looks up, they have an increase in frame rate(let’s say to 60 fps), and now Runservice Heartbeat will fire 60 times a second, meaning the player’s camera will rotate faster. RunService | Documentation - Roblox Creator Hub

Delta time is not the reason it is speeding up, my framerate remains the same. It is due to the angle of the camera and multiplying cframes, but I don’t know how to fix this

Fixed, the solution is this
camera.CFrame = CFrame.Angles(0,dt,0) * camera.CFrame