I don't mean framerate drops, It's more like the player is teleporty and moves much more slow than the player should. I can't find any method that would fix this (For example, simple changing the rotation will break joints, and CFraming already creates the 'lag') so I wanted to ask if anyone knew a better way to do this.

My code:

game:GetService("RunService").RenderStepped:connect(function()
				
				if angleY > zoomMax then
					angleY = zoomMax
				elseif angleY < -zoomMax then
					angleY = -zoomMax
				end
				
				local dir = Vector3.new(m.hit.p.x,0,m.hit.p.z)
				local x = 5 * math.cos(math.rad(angleX))
				local z = 5 * math.sin(math.rad(angleX))
				local y = 1 * math.tan(math.rad(angleY))		
				
				local camPosition = Vector3.new(x, y, z)
				camPosition = camPosition + chr.Torso.Core.Position	
				
				cam.CoordinateFrame = CFrame.new(camPosition, chr.Torso.Core.Position)*CFrame.new(2,4,7)
				chr.Torso.Mbox.CFrame = CFrame.new(chr.Torso.Mbox.CFrame.p,dir)*CFrame.Angles(0,math.rad(-90),0)	--This is the broken line, chr.Torso.Mbox is the collision box for my custom-ish player (It's welded to the real, invisible player.)
	end)
end)	

6 comments

0

Can you try taking out "game:GetService("RunService").RenderStepped:connect("? You are running the code faster than there are Frames. If you run it slower, it might work better for you?

0

RenderStepped fires every time there is a new frame

0

@YellowTide Yes, you are correct. However, I believe the point remains he should try running the script at slower intervals than every frame.

0

What is "angleY" and "zoomMax" and "angleX"? You didn't reference those in your given code.

0

Those are predefined earlier in the code, AngleX and AngleY are the angles that that camera is rotated at, zoomMax is a limit for AngleY.

0

Slowing it down using while wait() makes it look like it updates too slowly, using while renderstepped:wait() produced the same result as renderstepped:connect()