GuiService:GetGuiInset() returns 0,0,0,0 at first

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

3 Likes

I am also experiencing this issue. The GuiInset should be constant anyways, so why does it change during runtime?

1 Like

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()

1 Like

I reported this before here:

My only workaround is just to wait until the inset fixes itself, which kind of sucks because we shouldn’t need to do this in the first place.

1 Like

And here:

1 Like

Guess its just an undocumented “feature” and not anything they intend to fix.

Definitely not. They just haven’t got around to it yet, it seems