Issues with moving UI to mouse

I am using a image label as a mouse, and before you say to use mouse.Icon, I can’t in this case, it isn’t going to the correct place causing the rest of my script which bases off of the sizes and position of it, will not work.

c8sHTsZ

BrushCricleDecal.Position = UDim2.fromScale(input.Position.X - Canvas.AbsolutePosition.X, input.Position.Y - Canvas.AbsolutePosition.Y + 25)

thanks in advance.

1 Like

I think you should use mouse.Icon, it’s great.

1 Like

I can’t in this case, I need to be able to set size, track size, track position, and other things

Was just a little nod towards what you had already stated in the thread.

1 Like

Are you trying this to do this? if i’m wrong, it’s bc of my english.

local RunService = game:GetService("RunService")
local mouse = game.Players.LocalPlayer:GetMouse()

RunService.RenderStepped:Connect(function()
    BrushCricleDecal.Position = mouse.Hit.p
end)
1 Like

That returns with a vector value, not a udim2

If you want to use UDim2 and not Vector3, then THIS can help you.

image
They’re working with UI lol

local Mouse = game.Players.LocalPlayer:getMouse()
local BrushCricleDecal = script.Parent.ImageLabel

local X = Mouse.X / script.Parent.AbsoluteSize.X--Script.Parent being the ScreenGui
local Y = Mouse.Y / script.Parent.AbsoluteSize.Y
BrushCricleDecal.Position = UDim2.new(X,0,Y,0)

I don’t know if this will be useful but it works at least.
If IgnoreGuiInset is on for the ScreenGui you will have to use the Mouse.ViewSizeY for the Y coordinate in this case.

It works but why complicate it.
Going through those unnecessary steps might end up making it slower.

And in the end this is the result:

local Mouse = game.Players.LocalPlayer:GetMouse()

while wait() do
	GUI.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
end

What do you suggest I do then? I can’t seem to get it too work, since it appears to be many pixels off from it

Ensure your mouse icon has an AnchorPoint of 0.5, 0.5- this will center the position to what it needs to be. You can then fine tune offsets to make sure it has the most ideal position.

Like @TymDev said, just constantly set it’s position to UDim2.new(0,mouse.X,0,mouse.Y) and set the UI’s anchor point to (0.5, 0.5).