Unable to disable backpack

I’ve been using the following code to try and disable the backpack, however it hasn’t been working. The code is in a localscript, in StarterCharacterScripts, does anyone know how to fix this?
local a,b = pcall(function() game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false) end)

I have tried without the pcall, and no error is produced, and the ode before and after it still runs.

3 Likes

I put this exact code into a LocalScript under StarterCharacterScripts and didn’t change a single thing. It functioned just as expected, the backpack was disabled. Are you sure you’re actually experiencing an issue in which you’re unable to disable the backpack?

-- Some alternative code - point is to print the results of the pcall
local StarterGui = game:GetService("StarterGui")
local success, result = pcall(StarterGui.SetCoreGuiEnabled, StarterGui, Enum.CoreGuiType.Backpack, false)
print(success, result)

I’ve tried this exact code and it works fine, are you sure your using it as a local script? I suggest utilizing the console it’d give you some type of error if your somehow not doing this correctly.

1 Like

I’ve tried it in a localscript and in localscripts on the same game but it doesnt work as expected

How does it not work as expected? Please provide some extra details such as a screenshot of the current behaviour, your codebase and its hierarchy, and what you expect the outcome to be.

Where is the script in the game? It’ll need to be in a local service.

It’s currently in StarterCharacterScripts, and the code both before and after it runs

In my game, the script that disables that backpack is found on PlayerScripts, maybe you should try to put it there instead. Also, is the script local?

Localscript, also I tried using the code sent by colbert, that printed “true nil” as if it had ran, yet it didn’t do anything.

Got it, is the script disabled?

No, as I said earlier it prints “true nil”, and the code before and after it runs. After moving it to playerscripts it still didn’t work.

That’s really strange, can you open a empty baseplate and paste the script into the game?

This thread is from 2 years ago.

2 Likes