Accessing the CoreGui in a localscript

I’d like to read the absolute position of backpack icons so I can properly position some UI for any device. The issue is there seems to be some security checks in place to prevent this.

The element I want to access is just called “1”, so with this code

game:GetService("CoreGui"):FindFirstChild("1", true)

It should work however it throws this error

image

How can I get around this? Is there a alternative to properly position my UI elements?

1 Like

I believe you’re looking for PlayerGui or StarterGui. CoreGui is a Roblox service for their UI that the client does not have permission to access.

EDIT: Also, I recommend making your own backpack system. Roblox allows some disabling of the backpack if needed.

1 Like

Your guis should be in playerGui, not coreGui, unless you’re making a plug-in. Also, I’m pretty sure local scripts can’t access the core GUI so people can’t exploit by making local scripts.

Just looking to read it so that I can position my ui. Not putting anything in coregui

You can’t index CoreGui or any of its members/children. Doing so will result in an error. I don’t think there is anything you can do except fork the backpack UI and create your own using the fork.

On the topic, a backpack ui is very easy to make by cloning templates, using a list layout, and binding events to each

Best bet to get information about CoreGui content is to use Roblox Studio and Play Test.

  1. Open Studio
  2. File > Settings > Studio tab
  3. Look for subsection ‘Explorer’
  4. Show Core GUI in Explorer while Playing
  5. Close > Restart if you prefer to
  6. Play Test

Then you can get all the information about CoreGui that you’ll need to position things you want.

There is no way of indexing, viewing, or getting the values of anything that is inside CoreGui using a normal script or localscript as Roblox intends it to be protected. Malicious users could get the value of the ‘report game’ page’s frame position and kick/crash the user before they could even hit submit.

If you intend to attach something, best bet is to disable it from SetCoreGuiEnabled and fork your own version.

2 Likes

Oh! Sorry, didn’t read that. CoreGui can only (I think) be accessed by plugins.

For security reasons, you cannot access the CoreGui service or even reference it. CoreGui contains many important objects essential for the Roblox Engine to function, and they dont want somebody who doesn’t know what they’re doing using it. Your own GUIs should always be placed in PlayerGui and no where else.

If you need to reference the backpack, consider making your own backpack script, Roblox has made it incredibly easy to disable parts of the default UI with StarterGui

StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
2 Likes

I find not being able to read the CoreGUI elements very annoying. I don’t agree with the reasoning that simply reading those elements creates any issues. If a bad developer really wanted to use that data to block a GUI element they could do so with out it. It would be hacky and ugly but they could do it and I doubt it would matter to them what it looked like. There are very legitimate reasons for developers to want to (at min) read the details of the CoreGUI elements. For instance adding GUI elements in such a way they blend with other coreGUI elements without covering them or perhaps for adding indicator graphics for in-game tutorial based reasons. Without being able to read the coreGUI elements at runtime it makes it very difficult to implement these things while maintaining a prof look. At the very least these elements should be readable in server scripts/modules IMO.

2 Likes