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

How do I position a frame to the mouse's position?

I can't find anything about what I'm doing wrong. When I use this, the frame is not positioned to where the mouse is pointing. How do I fix this?

player = game.Players.LocalPlayer
mouse = player:GetMouse()
mouse.Move:connect(function()
Frame.Position = UDim2.new(0,mouse.x,0,mouse.y)
end)

4 comments

0

still no correct answer to this question ;-;

0

My problem was that the frame was inside of another frame that was smaller than the player's screen.

0

it's fixed now, heh.

1

omg

2 answers

✓ Accepted answer

You may want to add a loop

while wait() do
player = game.Players.LocalPlayer
mouse = player:GetMouse()
Frame.Position = UDim2.new(0,mouse.x,0,mouse.y)
end

Please remember to define what Frame means

Lua is case sensitive. There is no property of the mouse named x nor y, but there are properties named X and Y. So, to fix this, do the following fix.

player = game.Players.LocalPlayer
mouse = player:GetMouse()
mouse.Move:connect(function()
Frame.Position = UDim2.new(0,mouse.X,0,mouse.Y)
end)

This should have been an easy fix if you looked at the output. Also, read my bio, otherwise I may not help you on another question.

2 comments

0

Still does the same thing for me no matter if it's capitalized or not. It wont position the GUI to exactly where the mouse is pointing.

0

Capitalization in lua/any other programming language is VERY important, as doing Print() will error, but not print().

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