Can't align Gui to mouse position

Hi developers,

For some reason, I can’t get this Gui to line up with the mouse. The Gui is centred, can anyone help with this?

Script:

while wait() do
	script.Parent.Position = UDim2.new(0, game.Players.LocalPlayer:GetMouse().X, 0, game.Players.LocalPlayer:GetMouse().Y)
end
1 Like

Is the anchor point set to 0.5, 0.5?

1 Like

the script works for me

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local Mouse = Players.LocalPlayer:GetMouse()

RunService.RenderStepped:Connect(function()
	script.Parent.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
end)