Gui Rotation Lag

Hi,

I have a script that replicates the movement of a motor in a part into a Gui. It seems to work, however the animation is extremely laggy, i.e. studio becomes very slow and ping shoots from 34 to 100.

For what reason would updating the rotation property of a gui a single degree per wait() be so laggy?

Would this force me to use the TweenService for lag free rotation?

		for i = math.floor(math.deg(sg.Motor.CurrentAngle)), math.floor(math.deg(sg.Motor.DesiredAngle)), Dir do
				for k,child in next, this.Gui.Gate.gateFrame:GetChildren() do
					child.Rotation = i
				end
				for l,child in next, this.screenGui.Gate.gateFrame:GetChildren() do
					child.Rotation = i
				end
				wait()
			end

Many thanks!

why not use TweenService and Tween the Rotation of the Frame?

I’d recommend using tween service to complete this. It smoothly changes a value of your choice in a certain amount of time. For different easing styles, go here. Example:

local tweenInfo = TweenInfo.new(5) --5 seconds
local properties = { Rotation = 360 }

local function rotate()
    local tween = tweenService:Create(frame, tweenInfo, properties)
    tween:Play()
end

rotate()