I encountered a race condition when running the studio emulator where GuiService:GetGuiInset() sometimes returns Vector2.zero, Vector2.zero
Repo (LocalScript to place in StarterPlayerScripts):
local GuiService = game:GetService("GuiService")
local RunService = game:GetService("RunService")
print(GuiService:GetGuiInset()) -- 0, 0, 0, 0
RunService.Heartbeat:Wait()
print(GuiService:GetGuiInset()) -- 0, 58, 0, 0
So far I’ve only encountered this in the emulator, and only 50% of the time (indicating a race condition with core scripts), but it breaks part of my game’s UI as the entire UI tree initializes with the assumption that the topbar is 0 pixels tall.
This is only happening when the new topbar (58 pixel height) UI is visible
I only noticed this starting happening today; it was working fine before on the new topbar UI.
I added this block of code before my UI initializes as a workaround:
-- https://devforum.roblox.com/t/guiservicegetguiinset-returns-0-0-0-0-for-the-first-frame-of-the-game-with-new-topbar-ui/2973508
while GuiService:GetGuiInset().Y == 0 do
RunService.Heartbeat:Wait()
end