higbeaad
(Layla)
September 13, 2020, 8:18pm
#1
The example code snippet on the page for UserInputService:GetMouseLocation is broken.
This snippet attempts to move a GUI to the mouse location. However, the value returned by GetMouseLocation is a Vector2, while all GUI objects expect a UDim2 for their Position property.
This results in the following error being produced every frame:
Affected article:
https://developer.roblox.com/en-us/api-reference/function/UserInputService/GetMouseLocation
2 Likes
peraldon
(Jed)
September 14, 2020, 2:01pm
#2
Thank you for reporting this! I’ve just added it to our todo backlog.
Ozzypig
(Ozzypig)
September 17, 2020, 4:57pm
#3
Update: the code sample has been fixed - the change should be visible soon. For anyone searching for this problem, change line 7 from this:
gui.Position = mouseLocation
to this:
gui.Position = UDim2.new(0, mouseLocation.X, 0, mouseLocation.Y)
4 Likes
colbert2677
(ImagineerColbert)
September 18, 2020, 6:40pm
#4
Since you’re using 0 values for both scales, I’d assume fromOffset is also appropriate to use here? Possibly even canonical?
gui.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y)
1 Like
system
(system)
Closed
October 25, 2022, 10:16pm
#5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.