With the new topbar size, some of my old scripts that relied on the fact that the old inset was 36 pixels broke so I tried using GuiService:GetGuiInset() to get the new offset (58) instead. Instead of calling it every time my script used GetMouseLocation(), I figured I could just call it once at the top and save the value. However, for a couple frames after player scripts begin to run, the GuiInset is still zero. It takes about 0.2 seconds for GuiService to update the value
local t = tick()
game["Run Service"]:BindToRenderStep("a",1,function()
local a,b = game.GuiService:GetGuiInset()
if a ~= Vector2.new() then print("diff", tick()-t) end --diff at 0.189 sec
end)
I honestly do not want to add in any janky bloat arbitrarily long task.wait() lines to my code just to account for this and just hope that the GuiService would’ve started working by then.
Expected behavior
The correct GuiInset value should be calculated and updated PRIOR to the point at which localscripts in StarterPlayerScripts run, or during the process of the core scripts running
It changes as a result of the CoreGui not being fully loaded yet. The same reason you can’t use GetCore/SetCore off of runstart. My suggestion is to just wait for GuiService.TopbarInset to change (at least thats what I do to get around this) game:GetService("GuiService"):GetPropertyChangedSignal("TopbarInset"):Wait()