Extreme Performance Drop when changing UDim2 position on RenderStep?

This issue happens with changing a UDim2 on RenderStep. This is necessary because the game uses a custom animated cursor. The code causing this issue is below.

--ClientModule
runService:BindToRenderStep("MouseMove", 1, function()
    clientcore.input.Mouse.Move()
end)

--InputModule
local cursor = _G.gui.Cursor
local players = game:GetService("Players")
local player = players.LocalPlayer
local plrmouse = player:GetMouse()
Mouse.Move = function()
    cursor.Position = UDim2.new(0, plrmouse.X, 0, plrmouse.Y)
    --irrelevant code removed
end

This code causes massive FPS drops (from 120-200 down to 80) and this has been happening for months. Any solution would be greatly appreciated.

1 Like

Consider instead of :BindToRenderStep using

runService.RenderStepped:Connect(function()
--code here
)

I’m not sure if this will help but you should probably try.

I’ve already tried that and no, it would not make a difference.

Are you sure the Udim2 line is the lag cause? Maybe it’s another one?

Yes, I’m sure, it’s still happening with that one line