There is an equation you can use to get a GUI to be in the bottom right corner of the player's screen.
gui.Position = UDim2.new(1, -gui.AbsoluteSize.X, 1, -gui.AbsoluteSize.Y)
Since we know the size of the X and Y values of the helmet GUI will always be 100 pixels since you've set it in the script, we can just do the following for the helmet GUI's position:
helmet.Position = UDim2.new(1, -100, 1, -100)
What if we used Scale for the size instead? Well, we just use the AbsoluteSize property instead. AbsoluteSize is a property that has a Vector2 value that shows how big the GUI is on the player's screen.
helmet.Position = UDim2.new(1, -helmet.AbsoluteSize.X, 1, -helmet.AbsoluteSize.Y)
There is one problem with your code when doing this. If players re-size their game window, the GUI would not move to match the new game size window in game. This will be fine when using the offset values of a UDim2, but when using the scale values, you will need to keep changing the position to reflect the AbsoluteSize difference.
You could use events such as the Changed event to make this work.
helmet.Changed:connect(function()
helmet.Position = UDim2.new(1, -helmet.AbsoluteSize.X, 1, -helmet.AbsoluteSize.Y)
end)
I hope my answer helped you. If it did, be sure to accept it.
2 comments
I'm confused on the last part for AbsoluteSize.X and Absolute.Y
When your screen size changes and you're using scale for size, if you don't update the GUI's position, it won't fit. AbsoluteSize just reflects how big the GUI is on your screen in pixels. You won't need to worry about this for your GUI though.