How would I disable a player's backpack when they leave/enter a vehicle?

I’m trying to make a script for a plane in my game where a player enters, they cannot access their backpack, and when they die/exit, the backpack is enabled. I did this via a local script that was inserted to the player’s PlayerGui using the game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, value) line, but it did not work. What am I doing wrong?

Can you show the script in which the line is included?

Is value actually set to something?

Where you have value should be a boolean, true or false, or a variable holding it. To hide the Backpack, set value = false to show it, value = true

1 Like

It’s just a line where the script is pasted into the player’s player gui.

Yes, a value is assigned; I do it via a boolean that has its parent set to said local script.

What does your full code for it look like?

Simply doing

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

Should disable their backpack.


Not enough to account for if they leave the plane.

This is the code for the script:

local bp = script.disable:Clone()
bp.v.Value = false --- will be true or false depending on if they entered or left the pilot seat
bp.Disabled = false
bp.Parent = Player

Here’s the local script

local v = script.v
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, v.Value)

You have to detect when v.Value changes and change the Backpack Enabled Based on that.

1 Like

The current code will grab the value at the time of it enabling the script.

Script gets deleted after each insert.

@MrLonely1221 The code defaults as set to false but will not disable backpack.

Does it disable the backpack just from a regular local? Also, why do you need to make another script to do it? You can’t just do it from the local vehicle driving script?

My best answer is to make an alt backpack folder in the Player, not the Players character but the regular player inside game.Players, and when it gets in the car you can move everything that’s in the Players original backpack (and the tool on the character IF it has one on it) into the new alt backpack. Along with doing that you should also do game:GetService("StarterGui"):SetCoreGuiEnabled("Backpack", false) to prevent tools from being able to get to the Players backpack.

I recommend doing this all in a LocalScript to avoid issues with the SetCoreGuiEnabled section. No matter what it should still work on a LocalScript due to it being on the Players character and the Players backpack.

well, i recommend to use Region3 to see if the player is inside the plane or not, if not then enable the backpack by :

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)

and if entered then

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

and for the script where it checks if the player has died you use


	print(game.Players.LocalPlayer,"Died" , "- Client")

	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)


hopefully it works !