Hey everyone, so what I want to achieve is to make a ui appear at a user’s mouse location when they click it. However, I realized that the mouse.y position is a little bit off. The ui will be above my mouse by around 20-30 pixels. I think it might be because of the top bar in roblox. How do I work around this?
Did you disabled the
IgnoreGuiInSet of the ScreenGui?
The anchor points of the Gui holder is at 0.5 ?
This happens to me too, but only when that property is enabled (which would be actually ignoring the topbar) If its disabled a code like this works for me:
local Label = script.Parent:WaitForChild("ImageLabel") game:GetService("UserInputService").InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then Label.Position = UDim2.new(0, input.Position.X, 0, input.Position.Y) end end)
Ohh, I didn’t set ignoreguiinset. Just now I found a way to do it using mouse.x/mouse.
why use offset instead scale
No particular reason, just to not add a line to do the conversion between pixels which is what you got from
input.Position. Player will only be able to click a coordinate which is inside their screen, so if the click returns 500,800 px, its easy to use offset instead of scale, otherwise I should transform that pixels to scale based on the size of the player’s screen
Well offset is not the better choice in the matter due to other GUIs that use scale.
To get quick onto the issue, which is probably the
IgnoreGuiInSet property, using offset or scale makes no difference, plus the pixels gotten from the click cant be incorrect cause are based on the player’s click coordinates, it doesnt affect other GUIs if those are using scale. Finally, that was for testing purposes, to board the issue quickly, you are free to add an extra line that converts the pixels into scale, I dont see the point on overthinking if using offset or scale when thats not the issue and you can add it very quickly