How can i make a button that follow the player cursor while they're pressing down

ok what i need to do is simple, i want a button that will follow the player cursor while he is pressing down (Button.MouseButtonDown1) and stops when it reaches a certain position, note that the button uses the scale size not the offside ,

1 Like

If you’re talking about GUI dragging, go ahead and have a look at this tutorial’s marked solution:

1 Like

You could use RunService.

Check when the player is holding down the mouse, and you can use UserInputService to check when they released it.

Set a Boolean that when the mouse is released becomes false and sets the GUI in its place.

1 Like

perfect thats the answer, but it lacks only 1 thing, that thing is that i want to limit the button movement, so when it reaches a certain position it stops

1 Like

If you want it to be limited and not dragged outside a certain frame I reckon you can use AbsolutePosition and check if the AbsoluteSize of the dragged frame is not outside any corner. I never did such a thing before and I’m on mobile so I can’t really test but when I get home I can.

2 Likes