currentElev=0 currentRot=0 while wait()do if myMouse then mousePoint=myMouse.Hit.p targetVector=(mousePoint-parts.GunBase.CFrame.p).unit targetRotations=determineNewDirections(targetVector)for F=0,1,1 do newRotations=getSmoothRotation(targetRotations)TFE:FireServer("\082\111\116\097\116\101\084\117\114\114\101\116",parts,currentElev,currentRot)wait()end end end
-- Infinitely update the target position for the tank
currentElev = 0
currentRot = 0
while wait() do
	if myMouse then
		-- Position of mouse in world
		mousePoint = myMouse.Hit.p

		-- Vector from tank to mouse point
		targetVector = (mousePoint - parts.GunBase.CFrame.p).unit

		-- Determine where the gun should point
		targetRotations = determineNewDirections(targetVector)

		-- For each time we do all that math to determine the angle, we will smoothly rotate the gun towards it in 4 increments
		-- This means less lag (fewer calculations) but it's still smooth
		for i = 0, 1 do
			newRotations = getSmoothRotation(targetRotations)
			TFE:FireServer("RotateTurret", parts, currentElev, currentRot)
			wait()
		end
	end
end
