local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local gui = script.Parent
local function moveGuiToMouse()
local mouseLocation = UserInputService:GetMouseLocation()
gui.Position = mouseLocation
end
RunService:BindToRenderStep("moveGuiToMouse", 1, moveGuiToMouse)
The documentation explains that this code is supposed to have the GUI remain in the position of the Mouse’s location at all times, but then I get this error:
The gui’s Position is a UDim2, which takes four numbers. The mouse’s Position is a Vector2, only 2 numbers. Try gui.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y), which will position the ui based on the mouse’s absolute pixel location.
This is not an uncommon issue I have made a few requests for incorrect coding examples on the devhub and they have all been corrected, most times it happens because of simple mistakes or outdated API, if you see an error just make a post about it in the Devhub category and it will get updated quickly once the error is valid.