#UDim2
514 messages · Page 1 of 1 (latest)
i doubt.
** You are now Level 3! **
I have 4 years of experience
It uses scaling and offset in the same value
then whta do i do
^
wat...
mouse.X is offsett, haven't used mouse pos for a while
alr
because it is based on the size of the screen
i think i got it to wrk
offset is based on pixels
Yes, precentage
-- 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```
Like 0.5 is half of the screen independent of the size
make the anchor point for the cross hair 0.5,0.5
no clue what this thread meant
Just set the anchor point to 0.5?
?
Oh you already said that sorry
no clue what an anchor point is sorry
i think this suffices thoughj
but id listen to a better solution
It's where the position of the image is located
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
crosshair.Position = UDim2.new(0.5, 0, 0.5, 0)? this?
That will place it in the middle yes
this doesnt work
i just tried it
i reaslied that.
Is it 0.5, 0.5 or 0.5, 0?
i got it working
its even worser now
as far as my knowledge goes, the 2nd param is the multiplyer?
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)
I just checked and it works
iv had that exact code
its a bit offset on the Y T_T
You have the anchor point bad
maybe bc of roblox bar or smething
no offset needed
No
you can do it with just scale
@pine kite I'll handle this
dude i literally just did it
I did 5 minutes ago
...
oml
If you set the position to 0.5, 0, 0.5, 0 and anchor point to 0.5, 0.5 it works
exactly
thats using scale
oml what is the problem
And what's the problem with that
you said to use offset
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
i did not understand the concept of the UI elements
didnt realise they used %, my bad
It's so simple
literally any position on screen is a UDim2 position lol
Read this again
mb
-- 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
what isnt working then?
Y seems to be a bit lower for some reason
This is not what I've bin working on for 4 years. This is the basics
BRO
that perfectly in the middle
dude i think ur a bit gofy
I agree
Bro, it works why are you making an issue of nothing
i cant raycast with it if its not aligned
i can, but the visuals will be off
its saying "its good enough,"
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
** You are now Level 12! **
not misaligned
that's half the screen
ur using a gui element, to check if a gui is in the center, by making it at the center
u can see its off.
Set ignoreguilnset to true
go onto test and then go onto device and then select average laptop
It's perfectly in the middle
thats not accurate
you have to check gui on the device mode
ur so dumb
I always keep in avarage laptop mode when working with GUI's
** You are now Level 4! **
the red thing
Always
ur a little dumb too
fair
proof
-- 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
wait
this looks so complicated
It's basic
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
ayo get off my lawn
mb bro ;-;
joke, the lawns been destroyed allready xd
fr lol
Your problem is solved anyways
wdym you've done it
IT'S ALREADY IN THE CENTER
;-;
it shows the pixels
ples help i am confused asf
the yellow lines
Completly in the center is like 499, 498 but it's close
This is all just basic knowlege
I am on CrazieNewbs lawn and asking my question here
ok bro what the hell
** You are now Level 6! **
look
You guys are far from it
ur question isnt gonna be answerd here, its a warzone man
683*2 = 1366
THE ANSWER IS 0.5, 0.5!!!!!
why r there so many ppl on ur question lol
dont use roblox tools to work out a roblox error
wrong
thats not dead centre
no idiot
look at the screen shot
it shows the pixels
💀
fair
why is everyone on this question
and stuff
i am so confused
and why r there so many chats on it
cos it was actually quite more complex than it first seemed
who proved you right?
Yes it's 0.5
i tried it on iphone as well
idk
💀 💀 💀 💀 💀 💀 💀 💀 💀
i just moved it down by one pixel every time until the y axis was half the screen
u think itll break with dif resolutions?
srry but it seems my 5 months of experience is superior to your 4 yrs
laughs hysterically
bro im dying that u are so stubbern
majestic has joined my side and realised it was not centered xd
works
Wait
just a bit of brute force
stop using the guitool, to check if a gui is centered'
?
thats what i did
urs actually worked for some reason
yes but ur code doesnt work 😄
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
it hought we proved we are right rip
@pine kite
18 pixels is exactly half of the roblox top bar
this bar
0.5, 0.5 ignores the top bar
JUST SET THE SCREEN GUI TO IGNORE GUILSET
THAT SIMPLE
HOW
oml
IDIOT
aint no way boi
hahahha
IM THE NOOB D:<
mine is literally perfectly in the centre
I finally made you realize you were wrong
i still dont understand why you think im wrong
And let the facts take over you
nope, i wasnt
You were?
u just changed a property without saying anything
look at the size of the screen and the read the number on the yellow lines
the numbers are half of the screen
im never asking for help again i just cause pain and suffering oml
Here
what do i do about the width and height lol
bro realised that he's wrong lmao
you make another gui inside of it
LOL U EIDTED THE MSG
HE EDITED IT
wait what I did?
lol
BAGAGAGAGAHGAHGAHGAGAHGAHGA
idc what u say next u edited u have no proof surender
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
YOU ARE WRONG
Me
OH MY GOD
What
YOU'RE WRONG
Bro how are you still not convinced
HOW MANY TIMES DO I HAVE TO EXPLAIN THIS TO YOU
💀
How are you this stupid
look at the screen shot
ur not using the ignore thing
That's not the issue here
the distances from x = 0 and y = 0 are half of the proportions of the screen
also its close enough
u just suck at placing the dor
its meant to be topleft of the image not middle
dude the image is one pixel
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?
how do i compensate for the width and height? peakman please?
yeah but mine is more centered than yours
No
since my height n width is 4 i gotta offset it by half
the only reason its not always perfect is because you can have half a pixel
i have an idea guys
Read this again
im sorry you guys are idiots
But I just proved you wrong
show me yours
Here
oml i cnat close this post what.
im running
you are the one who doesnt understand
When you take a screenshot you don't get best quality and it's inaccurate. If that's what ur thinking
WAT
wait im confused
screenshots are pixelperfect if its a png xd
what are you saying im wrong about
?
only inacurate thing is anti aliasing when you zoom in
Sorry, I don't understand images that well. But I can asure you Roblox is not wrong, you are
whats this argument about
** You are now Level 5! **
thats what im trying to say
what are you talking about?
can we move to #🤡︱clownery lol
I'm talking about the discussion we are having
How don't you understand that you fucking idiot
so what am i wrong about then?
You are wrong about 0.5, 0.5 being inaccurate
i will show you what 0.5,0.5 looks like
Fine
wait when you say 0.5,0.5, are you talking about anchor point or position
position
this is 0.5,0.5
Yes?
case closed
quickly close the chat ;---;
1pixel off, unacceptable
fr
how.
right click the forum on the left
close post
close post reopens when any1 sends a msg lol
bye then ig
lmfao
lvl 2
Don't close we don't have a solution czu he don't understand
it closes when every1 leaves, else it wojt
Please just read what I’m sending. Trying to make you understand
Size can’t be 0
Roblox rounds the number down to 682
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
yes, topleft
Top left?
thats the origin no?
What do you mean
0.5 0.5 will be the topleft corner?
😨
:v
0.5, 0.5 is in the center
yeah
Because it’s set to thatå
what do the 0s represent
scale
It’s scaleX, offsetX, scaleY, offsetY
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
NO
yes
I don’t know what ur saying now
How am I wrong, you don’t even know how it fully works
this image uses 0.5 0.5
the centre is based on the top left corner right?
the centre is that wierd circle
in the topleft corner
That’s what you mean
That’s the anchor point🤦♂️
NO
...?
THEN WDYM
Find anchor point as a property in the gui
Image
It’s almost at the top of the properties
anchor point default is 0 0
Yes, top left
yes
** You are now Level 7! **
here
here i mean
Understand now?