Roblox Studio error

StarterGui:SetCoreGuiEnabled must be called from a local script

What StarterGui:SetCoreGuiEnabled must be called from a local script means in Roblox Studio, the two things that cause it with the code that triggers each, and the fix for each one.

Updated 12 November 20263 min readErrorLuauWritten by

In short

SetCoreGuiEnabled turns Roblox's built-in screen parts on or off, such as the backpack, the player list or the health bar. They are drawn on each player's own device, so only a LocalScript can change them. Move the call into a LocalScript in StarterPlayerScripts. To hide them for everyone, that one LocalScript runs for every player.

On this page
  1. What it means
  2. Causes and fixes
  3. Fix it with RoCode
  4. Find the line
  5. Questions
  6. Sources

What the message means

Output (example)
ServerScriptService.HideUI:3: StarterGui:SetCoreGuiEnabled must be called from a local script.

The server has no screen, so a server Script cannot change what a player sees. That is why the call is refused there.

The setting also resets when a player rejoins, so the LocalScript runs again each time, which is what you want.

Causes and fixes

Two things cause this error in practice. Each one below has the smallest code that triggers it, then the fix.

The call is in a server Script

A Script in ServerScriptService or Workspace runs on the server.

Breaks Script in ServerScriptService named HideUI
local StarterGui = game:GetService("StarterGui")

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

Put the same line in a LocalScript in StarterPlayerScripts.

Fixed LocalScript in StarterPlayer.StarterPlayerScripts named HideUI
local StarterGui = game:GetService("StarterGui")

StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)

The server decides when to hide it

Hiding the UI during a cutscene or round is decided on the server, so the call ends up in server code.

Breaks Script in ServerScriptService named Cutscene
local StarterGui = game:GetService("StarterGui")

local function startCutscene()
    StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
end

startCutscene()

Send a RemoteEvent to the clients, and let a LocalScript hide or show the UI when it arrives.

Fixed LocalScript in StarterPlayer.StarterPlayerScripts named UiToggle
local StarterGui = game:GetService("StarterGui")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local setUiHidden = ReplicatedStorage:WaitForChild("SetUiHidden") :: RemoteEvent

setUiHidden.OnClientEvent:Connect(function(hidden: boolean)
    StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, not hidden)
end)

-- on the server: setUiHidden:FireAllClients(true)

Fix it in your place

Paste the error, RoCode fixes it in your place

Copy the line from Output and paste it here. RoCode opens the script it names in the place you have open in Studio, works out which of the causes above it is, and edits the code there instead of handing you a snippet to paste.

For example: ServerScriptService.HideUI:3: StarterGui:SetCoreGuiEnabled must be called from a local script.

RoCode is an AI agent for Roblox Studio: it reads the scripts in the place you have open, finds the line and edits it there, and every change is an undo point. It runs on Windows or macOS with a desktop browser. Free to start, with free credits every day.

How to find the line that causes it

  1. Open Output (Window menu, or the Script tab), clear it with Ctrl+K (⌘K on Mac), and press Play.
  2. Find the first red line. It starts with the script's place in the Explorer and the line number, such as ServerScriptService.Shop:12:.
  3. Click the red line. Studio opens that script with the cursor on the failing line.
  4. Read the lines between Stack Begin and Stack End under it: they list the calls that led there, newest first, so you can see which function called the broken one.
  5. Still not sure which value is wrong? Add print(typeof(x), x) just above the line, or set a breakpoint on it and read the values in the Watch window.

Questions

How do I hide the backpack in Roblox?

In a LocalScript: game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false).

Can I hide the chat this way?

Enum.CoreGuiType.Chat is one of the types. Chat also has its own settings in TextChatService, such as the chat window's Enabled property.

Why does SetCore fail but SetCoreGuiEnabled work?

SetCore can fail early while the core scripts are still loading. See SetCore has not been registered.

Can RoCode fix it?

Yes. Paste the Output line into RoCode. It moves the call into a LocalScript in your open place, with a RemoteEvent when the server decides.

Sources and further reading

How the code was checked: every block marked Fixed passes Luau's strict type checker against Roblox's API definitions (luau-lsp, 12 November 2026), and every block marked Breaks compiles and fails only when it runs. The message wording was checked against the strings in Roblox Studio itself (macOS build installed on 12 November 2026) on 12 November 2026. A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.

More Roblox errors

All Roblox Studio errors

Stop hunting errors line by line.

RoCode reads the scripts in your open place, fixes the error where it happens and tells you what it changed. Free every day, no card required.