Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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)
0
still no correct answer to this question ;-; Jesse1240 59 — 6y
0
My problem was that the frame was inside of another frame that was smaller than the player's screen. Jesse1240 59 — 6y
0
it's fixed now, heh. Jesse1240 59 — 6y
1
omg greatneil80 2647 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

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

Ad
Log in to vote
0
Answered by 6 years ago

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.

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. Jesse1240 59 — 6y
0
Capitalization in lua/any other programming language is VERY important, as doing Print() will error, but not print(). hiimgoodpack 2009 — 6y

Answer this question