generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How do you make a textlabel go to your mouse click pos?

Previous Thread :: Next Thread 
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
18 Feb 2015 07:04 PM
Pretty simple, but how do you move like a textlabel to wherever you click?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Feb 2015 07:05 PM
TextLabel.Position = UDim2.new(0, mouse.X, 0, mouse.Y);
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
18 Feb 2015 07:06 PM
mouse.Button1Down:connect(function()
-- cnt's code
end)
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
18 Feb 2015 07:07 PM
mouse.Button1Down:connect(function()
TextLabel.Position = UDim2.new(0, mouse.X-TextLabel.Size.Offset.X/2, 0, mouse.Y-TextLabel.Size.Offset.Y/2);
end)

That will make it centered
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Feb 2015 07:09 PM
Well not really, you can have textlabels without a size so you would have to use TextBounds to be safe no?
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
18 Feb 2015 07:12 PM
if the text is centered wouldn't it still be centered?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Feb 2015 07:13 PM
TextLabels are (by default) from the top-left but you can change that to make it centered
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
18 Feb 2015 07:34 PM
I'm 99% sure they are defaulted to center.
Report Abuse
Rocky28447 is not online. Rocky28447
Joined: 11 Dec 2009
Total Posts: 2912
18 Feb 2015 07:36 PM
@Joey They aren't defaulted to center.
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
18 Feb 2015 07:38 PM
The position is set to something like:

(740,0)(503,0)

which is far beyond the screen.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Feb 2015 07:54 PM
I honestly don't remember so I'm not gonna say for sure that they are centered by default.
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
18 Feb 2015 07:56 PM
Mouse.X sets it depending on the screen size. How can I adjust this
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Feb 2015 07:57 PM
It doesn't matter, why would you need to adjust it?
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
18 Feb 2015 07:58 PM
Like I said it sets the position to something like (500,0,500,0), which isn't even on the screen, and I don't have hardly any experience with gui.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Feb 2015 07:59 PM
How would it do that, exactly?
Mouse.X and Mouse.Y are the screen coordinates of the mouse, not the 3D coordinates like mouse.Hit.X and mouse.Hit.Y are.
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
18 Feb 2015 08:00 PM
I have a frame inside a TextButton. Once the textbutton is clicked, the frame is visible and is moved to the mouse coordinates.

I don't know how it'd work for others, but it's no where near the screen, and sets it to a high number.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Feb 2015 08:01 PM
And look at my script again.
I put them as the 2nd and 4th components of the UDim2, not the 1st and 3rd. I used offset, not scale.
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
18 Feb 2015 08:05 PM
I see what you mean. Does it effect it that the Frame doesn't start in the top left corner? It starts in the middle of the screen and is then turned visible.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
18 Feb 2015 08:07 PM
It shouldn't affect it.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Feb 2015 08:07 PM
It doesn't matter where it starts, it would set the position of the textlabel to where your mouse is. If you want it to be centered you can do what Joey said?
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
18 Feb 2015 08:09 PM
script.Parent.OptionsMenu.Position = UDim2.new(0, mouse.X-script.Parent.Size.Offset.X, 0, mouse.Y-script.Parent.Size.Offset.Y)

It says Offset isn't a member of Size.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Feb 2015 08:10 PM
.X.Offset (and .Y.Offset) :)
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
18 Feb 2015 08:15 PM
Script.Parent's offset is 0, because it's all scale
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
18 Feb 2015 08:17 PM
If you want the "scale" of the mouse:
Mouse.X / GUI.AbsoluteSize.X
Mouse.Y / GUI.AbsoluteSize.Y
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
18 Feb 2015 08:25 PM
It still isn't working right. I'll upload a place tomorrow.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image