local mouse = game.Players.LocalPlayer:GetMouse() mouse.Move:Connect(function() script.Parent.Frame.Position = UDim2.new(mouse.X/1000,0,mouse.Y/1000,0) print(mouse.X/1000) end)
If you paste this into a localscript, the frame will have an offset from the mouse. How do I fix it so that the frame is where the mouse is, with no offset?
You can use ViewSizeX
and ViewSizeY
to get the dimensions of the players' screen/window.
local mouse = game.Players.LocalPlayer:GetMouse() local GS = game:GetService("GuiService") mouse.Move:Connect(function() script.Parent.Frame.Position = UDim2.new(mouse.X/mouse.ViewSizeX,0,mouse.Y/(mouse.ViewSizeY + GS:GetGuiInset().Y),0) print(mouse.Y/mouse.ViewSizeY) end)
You can also get the size of the topbar using the GuiService.