Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I convert mouse position to UDim2?

I'm trying to make a text label follow the player's mouse by creating an offset UDim2 and giving it the mouse X and mouse Y however this seems to be putting the text label off of the screen.

8 comments

0

local pos = UDim2.new(0,mouse.Hit.p.X,0,mouse.Hit.p.Y)

0

Thanks!

0

np

0

Actually, mouse.p.X seems to be in the negatives

0

Label is off screen

0

strange

0

always worked for me

0

Mouse.Hit.Position is for the 3D position the Mouse is pointing at

1 answer

✓ Accepted answer

Use offset values from Mouse.X and Mouse.Y;

Mouse.Move:Connect(function()
    local position = UDim2.new(0, Mouse.X, 0, Mouse,Y)
    GuiObject.Position = position
end)

1 comment

0

THANKS! :D

This discussion is preserved as it was. New answers, comments, and votes are closed.