How to center Image in ImageLabel

I’m trying to replace the roblox cursor with a screen gui. I need my image to NOT stretch I just want the center of whatever image I use to stick to the center of my image label which is in a ScreenGui in the startergui. So I tried using ScaleType: Slice for my image and it seems to give the right effect EXCEPT I cannot figure out how to get it centered, not only that but even if I could I don’t know how to get rid of the stupid lines coming off of it:
exampled

Anyways I messed around with SliceCenter and looked at the wiki and what not and still have no understanding of how it works. All I can seem to do is flip it to the other corner. So then I thought I would try something different I could just use stretch and set the size of the ImageLabel to the size of the image being used… EXCEPT that’s seemingly impossible (without doing it manually for every single image that I use which I may or may not know the size of)? So now I’ve decided to come back to centering the image, so I need help with the issues I stated from before. I don’t know how to center it using SliceCenter, and I don’t know how to get rid of the lines coming off of it. This is UNLESS there is in-fact a way to get the X and Y size of an image ID I wouldn’t mind using that method.

2 Likes

I don’t exactly understand what’s happening here, but have you tried adjusting anchor point? Sorry if this isn’t what you’re asking for.

Sorry it’s probably my fault for poor explanation of the issue. It already has an anchor point in the center, but when using slice it’s placed in the bottom left of the imagelabel for whatever reason and I don’t know how to center it. The really simple solution to this is just to set the size of the image label to the exact size of the image im using and it pretty much does exactly what I need, but it’s difficult if I want to use a bunch of different images from free models I have no way to know their exact size and it would be annoying to manually set each one.

This could and couldn’t be in the scripting area, I’m pretty sure Anchor points and UI/ GUIS rely on UI/GUI support. However it could lead into scripting in the script of your UI you could set a anchor point in there.
More into it I really don’t know what you are trying to do as it was poor explanation (Not to be rude).
if you can explain more we could try to help out.

Basically I’m trying to set the image (in this case the little dot at the bottom right of the image I linked in the OP) in the center of the label without stretching it. That is pretty much all, and it should be very simple, but I cannot seem to figure out how.

Edit: Also I should mention all the other options that aren’t slice will center it, but stretch the image as well. So I had to use slice. I cannot for the life of me figure out how to get my image in the center using slice.

Here are somethings that could help you:

  • Youtube (Search up excalty on what you need)
  • You could ask a UI/GUI professional

I in your case believe that YouTube could help you, there are so many ways on how to do it and it goes step by step. If you don’t like YouTube then I would just find someone who knows a bit about GUIs/UI, I really don’t know how else to help you. Sorry :C

Have you tried making the object that follows the mouse a Frame and then using AnchorPoint and a position scale of 0.5 to center the image in the frame?

You have to remember that players on Roblox use different size screens, so to center it you need to use the Scale section of the UDim2 to locate it.

1 Like

Since you have the anchor point as

0.5, 0.5

Your position should be:

0.5, 0, 0.5, 0

And you don’t really need SliceScale, use stretch and make the size in pixels:

Size = Udim2.fromOffset(5, 5)

And to add on with something, you should use

Mouse.Icon

To set a custom cursor

1 Like