#UDim2

514 messages · Page 1 of 1 (latest)

naive bone
#

mouse.X is offset I think

solar pollen
#

i doubt.

topaz chasmBOT
#

studio** You are now Level 3! **studio

solar pollen
#

though i am brand new to rlua

#

UDim2 uses wierd scaling

naive bone
#

I have 4 years of experience

solar pollen
#

its not pixel to pixel on screen

#

i need this

naive bone
#

It uses scaling and offset in the same value

solar pollen
#

then whta do i do

pine kite
solar pollen
#

wat...

pine kite
#

thats correct

#

scale is different

naive bone
#

mouse.X is offsett, haven't used mouse pos for a while

solar pollen
#

alr

pine kite
#

because it is based on the size of the screen

solar pollen
#

i think i got it to wrk

pine kite
#

offset is based on pixels

naive bone
#

Yes, precentage

solar pollen
#
-- Show crosshair
local mouse = player:GetMouse()
local screen = workspace.CurrentCamera.ViewportSize
local crosshair = player.PlayerGui:WaitForChild("FirstPerson").Crosshair
crosshair.Position = UDim2.new(mouse.X/screen.X, 0, mouse.Y/screen.Y, 0)
player.PlayerGui.FirstPerson.Enabled = true```
naive bone
#

Like 0.5 is half of the screen independent of the size

pine kite
#

make the anchor point for the cross hair 0.5,0.5

solar pollen
#

i checked

#

its directly in the centre

#

thanks for the help.

solar pollen
naive bone
#

Just set the anchor point to 0.5?

pine kite
#

?

naive bone
#

Oh you already said that sorry

solar pollen
#

no clue what an anchor point is sorry

solar pollen
#

but id listen to a better solution

naive bone
#

It's where the position of the image is located

solar pollen
#

vector2?

#

that strangely offset it

#

about 3/4 of the screen

naive bone
#

If you want to place it in the middle of your screen just make the position x scale 0.5, y scale 0.5

#

Why you need the mouse position for that

solar pollen
#

crosshair.Position = UDim2.new(0.5, 0, 0.5, 0)? this?

naive bone
#

That will place it in the middle yes

solar pollen
#

it seems oof

#

off

naive bone
#

wdym

#

Is the anchor point 0.5, 0.5

solar pollen
#

yup

#

for some reason

#

its aligned on the X but not the Y

pine kite
#

i just tried it

solar pollen
naive bone
#

Is it 0.5, 0.5 or 0.5, 0?

solar pollen
#

i swear it worekd once

#

then it turned out it was random.

#

0.5, 0

naive bone
#

0.5, 0.5

#

Then ur good

pine kite
#

i got it working

solar pollen
#

its even worser now

solar pollen
pine kite
#

i did this ```lua
local player = game.Players.LocalPlayer

local mouse = player:GetMouse()
local screen = workspace.CurrentCamera.ViewportSize
local crosshair = player.PlayerGui:WaitForChild("ScreenGui").Crosshair
crosshair.Position = UDim2.new(0.5, 0, 0.5, 0)

naive bone
#

I just checked and it works

solar pollen
#

iv had that exact code

solar pollen
pine kite
naive bone
#

You have the anchor point bad

solar pollen
#

maybe bc of roblox bar or smething

pine kite
#

no offset needed

naive bone
#

No

pine kite
#

you can do it with just scale

naive bone
#

@pine kite I'll handle this

pine kite
#

dude i literally just did it

naive bone
#

I did 5 minutes ago

solar pollen
#

its offset.

naive bone
#

Yes

#

What's the problem

solar pollen
#

ill go figure it out myself

#

"whats the problem" lol

pine kite
#

oml

bitter geyser
#

#

it seems to work from what i can see

naive bone
#

If you set the position to 0.5, 0, 0.5, 0 and anchor point to 0.5, 0.5 it works

naive bone
solar pollen
#

bro check ur eyes

#

i give up

pine kite
naive bone
pine kite
naive bone
#

Ik this guy is kinda bad explaining what he wants to achive. "I dont get how to convert mouse X & Y to UDim2 position"

#

I tried to answer that

#

First

solar pollen
#

i did not understand the concept of the UI elements

#

didnt realise they used %, my bad

naive bone
#

It's so simple

solar pollen
#

wowww 4years+ man

#

so simple

#

then help me solve this simple thing.

pine kite
naive bone
pine kite
#

mb

solar pollen
#
-- Show crosshair
local mouse = player:GetMouse()
local screen = workspace.CurrentCamera.ViewportSize
local crosshair = player.PlayerGui:WaitForChild("FirstPerson").Crosshair
crosshair.Position = UDim2.new(0.5, 0, 0.5, 0)
player.PlayerGui.FirstPerson.Enabled = true```
#

this is the half working code

#

X is aligned, Y is a bit missaligned

pine kite
#

what isnt working then?

solar pollen
#

Y seems to be a bit lower for some reason

naive bone
pine kite
#

mine isnt

solar pollen
#

BRO

pine kite
#

that perfectly in the middle

solar pollen
#

WDYUM IT IS MISSLAIGNED

#

U WANT PRROOF LOL

naive bone
#

No it's not

#

Ur doing it wrong

solar pollen
pine kite
#

dude i think ur a bit gofy

naive bone
#

I agree

solar pollen
#

same

#

its such a trivial task and for some reason this image wont align thats why.

naive bone
#

Bro, it works why are you making an issue of nothing

solar pollen
#

i cant raycast with it if its not aligned

#

i can, but the visuals will be off

#

its saying "its good enough,"

naive bone
#

You know it's in the middle because you set the scale to Udim2.new(0.5,0,0.5,0)

#

So it's in the middle there you have it

#

Nothing to worry about

#

Move on

#

I'll stop wasting my time

pine kite
topaz chasmBOT
#

studio** You are now Level 12! **studio

pine kite
#

not misaligned

solar pollen
#

bro

#

LOL

pine kite
#

that's half the screen

naive bone
solar pollen
#

ur using a gui element, to check if a gui is in the center, by making it at the center

solar pollen
naive bone
#

Set ignoreguilnset to true

pine kite
# naive bone

go onto test and then go onto device and then select average laptop

naive bone
#

It's perfectly in the middle

pine kite
#

you have to check gui on the device mode

pine kite
naive bone
#

I always keep in avarage laptop mode when working with GUI's

solar pollen
topaz chasmBOT
#

studio** You are now Level 4! **studio

solar pollen
#

the red thing

naive bone
#

Always

solar pollen
#

is the perfect pixel centre

#

X is aligned

#

Y is offset

naive bone
pine kite
solar pollen
#

im the dumbest here guys

#

but its not aligned 😦

naive bone
#

It is

#

Want proof?

solar pollen
naive bone
#

-- Show crosshair
local mouse = player:GetMouse()
local screen = workspace.CurrentCamera.ViewportSize
local crosshair = player.PlayerGui:WaitForChild("FirstPerson").Crosshair
crosshair.Position = UDim2.new(0.5, 0, 0.5, 0)
player.PlayerGui.FirstPerson.Enabled = true

#

That's your code and that's the proof

#

As you can see it's 0.5 which means half of screen

#

In the middle

pine kite
#

wait

high osprey
#

this looks so complicated

naive bone
#

It's basic

high osprey
#

my question looks like its simple compared to this

#

;-;

naive bone
#

It's very simple, I can make you understand

#

What's your question

high osprey
#

my question isnt abt this but ok ill just ask here

#

i have a script that runs all the way through with no error signs

#

but the npc isnt playing the walk animation

solar pollen
#

ayo get off my lawn

high osprey
#

mb bro ;-;

solar pollen
#

joke, the lawns been destroyed allready xd

high osprey
#

fr lol

naive bone
#

Your problem is solved anyways

pine kite
#

ok i've done it

#

i've got it dead centre

naive bone
#

wdym you've done it

pine kite
#

perfectly

naive bone
#

IT'S ALREADY IN THE CENTER

high osprey
solar pollen
#

COUNT THE PIXELS OK

#

IV DONE IT

pine kite
#

it shows the pixels

high osprey
pine kite
#

the yellow lines

naive bone
#

Completly in the center is like 499, 498 but it's close

#

This is all just basic knowlege

high osprey
pine kite
#

if you want it exactly in the middle you have to make the size of the ui 0,0,0,0

naive bone
#

ok bro what the hell

topaz chasmBOT
#

studio** You are now Level 6! **studio

pine kite
#

look

naive bone
#

You guys are far from it

solar pollen
solar pollen
pine kite
#

683*2 = 1366

naive bone
#

THE ANSWER IS 0.5, 0.5!!!!!

high osprey
#

why r there so many ppl on ur question lol

solar pollen
#

dont use roblox tools to work out a roblox error

pine kite
#

thats not dead centre

#

no idiot

#

look at the screen shot

#

it shows the pixels

naive bone
#

Bro what

#

This is actually insane

#

How are you this stupid

pine kite
#

366*2=768

#

what is the size of the screen

#

1366x768

#

booyah

#

i win

#

ez

high osprey
#

;-;

#

please

#

calm down

naive bone
#

💀

pine kite
#

im srry

#

im just very excited

high osprey
#

fair

pine kite
#

that i was able to do it

#

cos im so handsome and smart

high osprey
pine kite
#

and stuff

high osprey
#

i am so confused

naive bone
#

Bro

#

You just proved me right

high osprey
#

and why r there so many chats on it

high osprey
#

its fine

pine kite
#

cos it was actually quite more complex than it first seemed

pine kite
naive bone
#

Yes it's 0.5

pine kite
#

no

#

the position is

#

{0.5, 0},{0.5, -18}

naive bone
#

why -18?

#

Bro what

pine kite
#

i tried it on iphone as well

pine kite
solar pollen
#

Yo

#

IT WORKED

#

IT WORKS

#

I LVOE YOU

#

WHY DOES IT WORK

#

lol.

naive bone
#

💀 💀 💀 💀 💀 💀 💀 💀 💀

pine kite
#

i just moved it down by one pixel every time until the y axis was half the screen

solar pollen
#

u think itll break with dif resolutions?

pine kite
naive bone
#

If you guys actually believe that's true. Please try in game

#

I'm dying

pine kite
#

laughs hysterically

solar pollen
#

bro im dying that u are so stubbern

#

majestic has joined my side and realised it was not centered xd

pine kite
naive bone
#

Wait

pine kite
#

thats perfectly centered

#

to the pixel

solar pollen
pine kite
#

just a bit of brute force

solar pollen
#

perfectly aligned

#

to topleft

#

😄

naive bone
solar pollen
# naive bone

stop using the guitool, to check if a gui is centered'

pine kite
#

thats what i did

naive bone
#

hahahahhaha

#

You guys confused now?

solar pollen
#

urs actually worked for some reason

solar pollen
naive bone
#

Well guess what it didn't

#

My code worked please

#

please just realize how wrong you are

#

I don't want you moving on thinking roblox is wrong and ur right

#

Listen to urself

solar pollen
#

it hought we proved we are right rip

naive bone
#

How?

#

Look at the image i sent

solar pollen
#

@pine kite

#

18 pixels is exactly half of the roblox top bar

#

this bar

#

0.5, 0.5 ignores the top bar

naive bone
#

JUST SET THE SCREEN GUI TO IGNORE GUILSET

solar pollen
#

this has to be the most chaotic thread

#

WHAAT

naive bone
#

THAT SIMPLE

solar pollen
#

HOW

pine kite
naive bone
#

IDIOT

pine kite
#

aint no way boi

naive bone
#

hahahha

solar pollen
#

U BRUTE FORCED IT LOL

pine kite
solar pollen
#

IM THE NOOB D:<

naive bone
#

Yes you are

#

@pine kite too

pine kite
#

i had to brute force it anyways

#

no

naive bone
#

Finally

#

You understand

pine kite
#

mine is literally perfectly in the centre

naive bone
#

I finally made you realize you were wrong

pine kite
#

i still dont understand why you think im wrong

naive bone
#

And let the facts take over you

solar pollen
#

it worlked and im using 0.5, 0.5

naive bone
#

Yes

#

Exactly

solar pollen
naive bone
#

You were?

solar pollen
#

u just changed a property without saying anything

pine kite
#

the numbers are half of the screen

solar pollen
#

im never asking for help again i just cause pain and suffering oml

naive bone
#

Wait

#

just wait

naive bone
solar pollen
#

what do i do about the width and height lol

pine kite
pine kite
solar pollen
#

LOL U EIDTED THE MSG

solar pollen
naive bone
#

wait what I did?

solar pollen
#

lol

pine kite
#

BAGAGAGAGAHGAHGAHGAGAHGAHGA

solar pollen
#

idc what u say next u edited u have no proof surender

naive bone
#

Mabye I typed something wrong!!!???🙀

#

Anyways, I said that 0.5, 0.5 was right the whole time wasn't I?

#

And you said it was wrong...

#

And who was right...

#

ME

pine kite
naive bone
#

Me

pine kite
#

OH MY GOD

naive bone
#

What

pine kite
#

YOU'RE WRONG

naive bone
#

Bro how are you still not convinced

pine kite
#

HOW MANY TIMES DO I HAVE TO EXPLAIN THIS TO YOU

naive bone
#

💀

pine kite
#

please

naive bone
#

How are you this stupid

pine kite
#

look at the screen shot

solar pollen
#

ur not using the ignore thing

naive bone
#

That's not the issue here

pine kite
#

the distances from x = 0 and y = 0 are half of the proportions of the screen

solar pollen
#

also its close enough

#

u just suck at placing the dor

#

its meant to be topleft of the image not middle

solar pollen
#

how do u even get that fancy lines

#

xd

pine kite
#

dude the image is one pixel

naive bone
#

The thing you are doing wrong is not conciedring size can't be 0. And since roblox is rounding down it set to 1 smaller. It's actually 682.9999

#

Understand now?

solar pollen
#

how do i compensate for the width and height? peakman please?

pine kite
naive bone
#

No

solar pollen
#

since my height n width is 4 i gotta offset it by half

pine kite
#

the only reason its not always perfect is because you can have half a pixel

naive bone
#

It's not a half pixel

#

It's 0.0000000001 pixel

solar pollen
#

i have an idea guys

pine kite
#

im sorry you guys are idiots

naive bone
#

But I just proved you wrong

pine kite
pine kite
#

lets look at the exact position

#

using pixels

solar pollen
#

oml i cnat close this post what.

naive bone
#

Don't do it

#

I want to make him understand

solar pollen
#

im running

pine kite
naive bone
#

When you take a screenshot you don't get best quality and it's inaccurate. If that's what ur thinking

solar pollen
#

WAT

pine kite
#

wait im confused

solar pollen
#

screenshots are pixelperfect if its a png xd

pine kite
#

what are you saying im wrong about

solar pollen
#

only inacurate thing is anti aliasing when you zoom in

naive bone
#

Sorry, I don't understand images that well. But I can asure you Roblox is not wrong, you are

solar pollen
#

whats this argument about

topaz chasmBOT
#

studio** You are now Level 5! **studio

pine kite
solar pollen
#

can we move to #🤡︱clownery lol

naive bone
#

I'm talking about the discussion we are having

#

How don't you understand that you fucking idiot

pine kite
#

so what am i wrong about then?

naive bone
#

You are wrong about 0.5, 0.5 being inaccurate

pine kite
#

i will show you what 0.5,0.5 looks like

naive bone
#

Fine

pine kite
# naive bone Fine

wait when you say 0.5,0.5, are you talking about anchor point or position

naive bone
#

position

pine kite
#

this is 0.5,0.5

naive bone
#

Yes?

solar pollen
#

case closed

bitter geyser
#

quickly close the chat ;---;

solar pollen
#

1pixel off, unacceptable

bitter geyser
#

fr

solar pollen
#

how.

bitter geyser
#

right click the forum on the left

solar pollen
#

is 682 instead of 683 lol

bitter geyser
#

close post

solar pollen
#

close post reopens when any1 sends a msg lol

pine kite
#

bye then ig

solar pollen
#

LOL

#

iv sent so many msgs im lvl5

#

i was like lvl1

naive bone
#

Don't close we don't have a solution czu he don't understand

solar pollen
#

it closes when every1 leaves, else it wojt

naive bone
#

Size can’t be 0

solar pollen
#

wat

#

target maj not me lol

#

i9 was kidding

naive bone
#

Roblox rounds the number down to 682

solar pollen
#

however

#

1366*0.5?

#

doesnt need rounding?

naive bone
#

The yellow line takes the dictance between the edge of the gui to the edge of the screen. The edge of the gui is not in the center

solar pollen
#

yes, topleft

naive bone
#

Top left?

solar pollen
#

thats the origin no?

naive bone
#

What do you mean

solar pollen
#

0.5 0.5 will be the topleft corner?

naive bone
#

😨

solar pollen
#

:v

naive bone
#

0.5, 0.5 is in the center

solar pollen
#

oh ur right mbad

naive bone
#

yeah

solar pollen
#

whats the size?

#

why is it 0,100 0, 100

naive bone
#

Because it’s set to thatå

solar pollen
#

what do the 0s represent

naive bone
#

scale

solar pollen
#

WAIT I AM RIGHT

naive bone
#

It’s scaleX, offsetX, scaleY, offsetY

solar pollen
#

oh

#

i see what u mean

#

0.5 0.5 is the topleft corner

#

but when using this tool

#

it takes the centre of the element

#

thats why hes wrong

naive bone
#

NO

solar pollen
#

yes

naive bone
#

I don’t know what ur saying now

solar pollen
#

if u disagree then ur wrong

#

watch

naive bone
#

How am I wrong, you don’t even know how it fully works

solar pollen
#

this image uses 0.5 0.5

naive bone
#

Yes

#

It’s in the middle

solar pollen
#

the centre is based on the top left corner right?

#

the centre is that wierd circle

#

in the topleft corner

naive bone
#

That’s what you mean

solar pollen
#

yes.

#

but the yellow lines, they are centred to the image

naive bone
#

That’s the anchor point🤦‍♂️

solar pollen
#

yes.

#

anchor point is centre

naive bone
#

NO

solar pollen
#

...?

solar pollen
naive bone
#

Find anchor point as a property in the gui

#

Image

#

It’s almost at the top of the properties

solar pollen
#

anchor point default is 0 0

naive bone
#

Yes, top left

solar pollen
#

yes

naive bone
#

Set to 0.5, 0.5

#

Half half

solar pollen
# pine kite

when he was measuring his anchor point was 0 0

naive bone
#

Not why is wrong

#

He had 0.5,0.5

#

0.5,0.5 anchor point gives the same results

topaz chasmBOT
#

studio** You are now Level 7! **studio

naive bone
solar pollen
#

at least this made me understand anchors

#

evertything works