Hello! I am currently working on a pet UI for my game but I’m facing an issue positioning a frame to the client’s mouse position.
-- This is my current code
Frame.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
I tried following instructions from all the topics below but none of them worked for me.
Any help is appreciated!
Try to use scale and not offset.
I’ve also got something to work and it stays in the same position as your mouse
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
script.Parent.Frame.Position = UDim2.new(mouse.X/mouse.ViewSizeX, 0, mouse.Y/mouse.ViewSizeY, 0)
Is the frame a child of some other frame? Because if so the mouse’s 0,0 position is at the top left of the screen, while the frame’s 0,0 position is at the top left of its parent.
If that’s the issue you can fix by subtracting the parent’s AbsolutePosition from the mouse position.