:GetMouseLocation() returning incorrectly?

I have:

Services.RunService.RenderStepped:Connect(function()
	local Location = Services.UserInputService:GetMouseLocation()
	warn(Location)
	warn(UDim2.fromOffset(Location))
	script.Parent.Position = UDim2.fromOffset(Location)
end)

and the Location is {0, 0} no matter where my mouse is.
Why is that?

Because you’re passing a Vector2 value to the UDim2.fromOffset function, you need to pass each axis separately. try this:

Services.RunService.RenderStepped:Connect(function()
	local Location = Services.UserInputService:GetMouseLocation()
	local Offset = UDim2.fromOffset(Location.X, Location.Y)
	warn(Location, Offset)
	script.Parent.Position = Offset
end)
1 Like