Mouse.X / Y / Z appearing offcentered

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I would like this to be centered on the cursor’s X axis, I am not sure what is wrong with it.

  2. What is the issue? Include screenshots / videos if possible!


    Sorry if this is hard to depict but it is not parented to the cursor.

  3. What solutions have you tried so far?

Frame.Position = UDim2.new(0,Mouse.X - 50,0)

I feel uncomfortable using this because I am uncertain if this is for my resolution. In other words I do not know what is causing this problem.

LocalScript

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local StarterGui = game:GetService("StarterGui")
local Frame = script.Parent.Parent.HoverText

for i,button in pairs(script.Parent.Frame:GetChildren()) do
	if button:IsA("TextLabel") then
		button.MouseEnter:Connect(function()
			Frame.Visible = true
		end)

		button.MouseLeave:Connect(function()
			Frame.Visible = false
		end)

		Mouse.Move:Connect(function()
			Frame.Position = UDim2.new(0,Mouse.X,0)
		end)
	end
end

Hierarchy

image

So I don’t particularly understand, but from what it seems, you can’t get the GUI to move and allign with your mouse.

Mouse.Move:Connect(function()
			Frame.Position = UDim2.new(0,Mouse.X/(Frame.Size.X/2),0,(0,Mouse.Y/(Frame.Size.Y/2))
		end)

This should work.

I received an error trying that code and that I have fixed but I am encountering another one

attempt to perform arithmetic (div) on UDim and number

using Frame.Position = UDim2.new(0,Mouse.X/(Frame.Size.X/2),0,0,Mouse.Y/(Frame.Size.Y/2))