UI object trails behind mouse in renderstepped,but only with plugins

I’m not sure if this is a bug, but I’ve been encountering this really bizarre issue and wasn’t sure where else to post it.

For dragging a UI object, I’m positioning it to the mouse on RenderStepped.

This is the code(both for the plugin and the local script in-game)

local function fn()
    frame.Position=UDim2.new(0,Mouse.X,0,Mouse.Y);
end
game:GetService("RunService"):BindToRenderStep("mouse",Enum.RenderPriority.Last.Value,fn)

This works fine in game in a starterplayerscript

https://i.gyazo.com/e4423ef29e87b20bf97f5e2d548e8fe0.mp4

In a plugin however, with the same source, you can see how it trails behind

https://i.gyazo.com/fd7e0171a6328c5364884e52e761c3ef.mp4

It’s almost as if updating mouse x/y is delayed but only for plugins.

Is there any reason behind this or am I doing something wrong?

Simple repo plugin
GuiPlugin.rbxm (2.6 KB)

Thanks

2 Likes

This is because the Windows cursor is updated before the Roblox cursor. Since in-game, the cursor is rendered by Roblox, it renders in sync with other game UI, whereas in Studio, only the UI is rendered by Roblox - the cursor is instead drawn by Windows.

1 Like

That makes sense

Well that’s incredibly frustrating for plugin development :frowning: guess we’ll have to stick with delayed dragging then

1 Like