TextBounds does not function in the CoreGui

Since the TextBounds property of text GUI objects contains the total pixel size of a block of text, it can be used to determine the necessary size of the parent GUI object. I went to do this for a plugin and found that TextBounds does not update while the GUI object is in the CoreGui – it remains at 0,0 and does not change no matter what is done to the GUI object. I was in run mode

when I was testing this, so it certainly isn’t an issue of TextBounds only being updated when the game is running. It seems to only update in the PlayerGui, but as this is a plugin that isn’t exactly possible. TextBounds should update in the CoreGui as well.

Are we running the same version? This works fine:

l = Instance.new("TextLabel")
print(l.TextBounds) -- 0, 0
l.Parent = game.CoreGui
print(l.TextBounds) -- 27, 12

Perhaps it’s because you’re running from a plugin. I recall that plugins run before just about everything else, so maybe the TextBounds needs time to initialize.

After a little investigation, this appears to be the case. I would say to hook into the Changed event and update when TextBounds changes, but it doesn’t seem to fire at that point when it’s initialized. It does fire when changes to the text occur, though. I believe a similar problem happens with ScreenGui’s AbsoluteSize, where it takes a moment to initialize. I think the only solutions would be to either wait a bit, or continuously poll the property until GUIs are finished doing whatever the heck they’re doing. Or yell at roblox devs to make sure that GUIs are initialized before scripts start running.

I updated to the most recent version of Studio ( and still had the issue. It’s not due to plugins being loaded first either. The code gets executed after I have selected two items in the explorer and clicked a button, and then even after that code has executed and the text set, I wait a full second and the TextBounds is still at 0.

If you want to take a look at it, insert the plugin through:
game.InsertService:LoadAsset(218876717).Parent = workspace

Open the script and head on down to line 178. I’ve been using Hotswap (thank you) to test it, but I tested the published plugin as well and still had the same issue, so it’s not due to Hotswap either.

Figured it out. TextBounds is always [tt]0, 0[/tt] when a NetworkServer is present, which your plugin inserts. Since a server would normally never have graphics enabled, it was probably assumed that text would never be rendered. Definitely a bug.

:frowning: I can’t refrain from using the NetworkServer either because the character inserter needs it to be able to access HttpService in order to get a user’s characterappearance. Oh well. Guess I’ll just continue using the set value until if/when they fix it.

In general, plugins shouldn’t be inserting NetworkServers. They should really just make HttpService usable without a NetworkServer for plugins.