Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there any way to fix ScreenGUI to fit to player's screen?

local stageread = Instance.new("ScreenGui")
stageread.Parent = script.Parent

local player = game.Players.LocalPlayer
local text = Instance.new("TextLabel")
text.Parent = stageread
text.Position = UDim2.new(0, 1350, 0, 450)
text.Size = UDim2.new(0, 250, 0, 100)
text.Font = "Arial"
text.FontSize = "Size24"
text.TextWrapped = true
text.BackgroundTransparency = 1
text.TextColor3 = BrickColor.White().Color
while true do
local left = 14 - player.leaderstats.Stage.Value
text.Text = (" "..player.leaderstats.Stage.Value.. " Of 14! " ..left.. " stages left")
wait(.1)
end

I have this script here, and it works, but when I go in the actual game it doesn't fit the screen like it did in Studio. Can someone help me with this? I've seen games before have GUI that changes as the window size changes to fit the screen, and I need help doing that.

1 answer

✓ Accepted answer

You need to use scale rather than offset.

text.Position = UDim2.new(0, 1350, 0, 450)
text.Size = UDim2.new(0, 250, 0, 100)

I can't help specifically as I can't really tell what you want this GUI to look like, but I can tell you a bit about using scale.

These two lines are using offset, which is measured in pixels. You should use *scale * instead, which becomes super easy when you've used it a bit. UDim2.new(scaleX,offsetX,scaleY,offsetY) is the format. Scale can be any value from 0 to 1, where 1 is full width of the screen and 0.5 would be half the screen etc.

A note: If you want it in the centre of the screen, you need to remember that the GUI 'anchors' to the top corner so a GUI of size 0.5x0.5 must be placed at (0.25,0,0.25,0) As 0.25 above + 0.5 height of GUI + 0.25 below = 1 (size of screen)

You can read more here: http://wiki.roblox.com/index.php?title=UDim

2 comments

0

So should I just leave the offset coordinates as 0?

0

Yeah, just play around with the scale and offset until you get something you want. Using large offsets will cause noticeable differences on difference screens though.

This discussion is preserved as it was. New answers, comments, and votes are closed.