My main question for this topic is how do I scale all GUIS perfectly?
I’m aware of plugins that automatically edit some position, size, and offset properties. (Like the GUI Rescaler plugin.) However, I was wondering how to do this without using plugins.
I’ve reviewed some code, and I have a couple of questions:
Does this involve AbsoluteSize?
Is there a formula or a way to do this “with math” in a script?
That explains the second picture, is the first picture taken in studio test mode or just in studio?
I have one suspicion that may or may not be correct, but it might be possible that when you join it in studio, you may need to add a :WaitForChild() to wait for the actual player to spawn in before it causes the change (This is just a wild assumption)
Other than that, the code should work fine, and like I said above, the code creates the gui in the second picture.
Don’t use code. Scaling UI within studio using properties is incredibly easy. The images you showed below, you could easily just take the code you’re using, and put that into the default property of the frame.
The issue is that the code wont change it until the game is played, so any size constraints you have on the frame will be displayed in studio mode until it is tested.
if you want it to look like the second photo in studio, you have to change the size of the GUI in StarterGui.TestGUI.Frame manually. Click size, then change it to {0.5,0},{0.5,0} and do the same with the anchor point.
Coding wise:
I suggest doing something like this:
local LocalPlayer = game.Players.LocalPlayer
local PGUI = LocalPlayer.PlayerGui
local Frame = PGUI:WaitForChild("TestGUI").Frame
if game.Players:WaitForChild(LocalPlayer.Name) then
print("Changed!")
Frame.Size = UDim2.fromScale(.5,.5)
Frame.Position = UDim2.fromScale(.5,.5)
Frame.AnchorPoint = Vector2.new(.5,.5)
end
This will make it so when a player enters your game, it changes to the correct position that you wanted on the screen/
I don’t want it to look like the second picture. I just wanted it to look like the first picture, but scaled properly on all devices so everyone can see the same thing.
Oh! then just delete the script haha, what you have in the properties is fine, I thought you wanted what was in the second photo.
Just keep what you have ( {1,0},{0.1,0} ) , cause since you used scaling, this will automatically adjust it’s length for all devices (Mobile, different computers ect)
Offset is when you want an absolute value ( one that doesnt change no matter the size of the screen)
You have the right idea though, just continue using Scaling instead of offset
Before I never used Scale and Position when editing UI’s, I always used to drag them across the screen. That’s why I made this topic for help on how to rescale them.
I’ll just use properties from now on to scale my UIs, thank you guys for the help!
When UIs are first inserted, their position is automatically put in scaled units however the size is always in offset units, so when you click and drag, it will keep its position, however if you click and resize , it will resize it in offset units.
Quick fix
I always immediately just type {0.1,0},{0.1,0} into the size bar, this sets it to keep the scale units when you drag to resize