Remove backpack while seated not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to fix my script that hides a players backpack while seated.

  1. What is the issue? Include screenshots / videos if possible!

The darn script wont work even though it looks like it’d work.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I haven’t found any solutions, I found other post but none we’re equivalent to my issue or helping me.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local seat = script.Parent
local starterGui = game.StarterGui


seat:GetPropertyChangedSignal("Occupant"):Connect(function(player) 

	if seat.Occupant then

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

	else

		starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)

	end
end)

I’ve tried this script in the car seat, I had a feeling this wouldn’t work, so in conclusion…

local seat = script.Parent.Parent
local starterGui = game.StarterGui


seat:GetPropertyChangedSignal("Occupant"):Connect(function(player) 

	if seat.Occupant then

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

	else

		starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)

	end
end)

Then I ended up putting a ‘script.Parent.Parent’ in StarterGUI. Still not working.

Any help?

17 Likes

You are changing startergui, but you need to change playergui instead

5 Likes

is this a local script or a script? where did you put this script?

5 Likes

max characterssssssssssssssssssssssss

4 Likes

How do I do something like that exactly?

4 Likes

instead of

starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)

use

player.PlayerGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
2 Likes

You can’t use a LocalScript in the workspace. Do you have the seat in the workspace, and this script as a descendant of it?

3 Likes

I tried putting the script in the seat using script.Parent, still no outcome.

I also tried using that ^

Still no outcome

Then I tried using player.PlayerGui as a child of the seat, and still no outcome!

Why is this so difficult.

1 Like

image

1 Like

Reference your seat via LocalScript inside of StarterCharacterScripts. Also I added a check to ensure it only occurs when the Client is sitting down themselves, not someone else.

local seat = workspace:WaitForChild("Seat") -- YOUR SEAT HERE
local starterGui = game.StarterGui


seat:GetPropertyChangedSignal("Occupant"):Connect(function(player) 
	if seat.Occupant and ( seat.Occupant == game.Players.LocalPlayer.Character.Humanoid ) then
		starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
	else
		starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
	end
end)
3 Likes

Is it possible to call all the drive seats or is that a whole different story?

But for one seat in the game this works perfectly!

Maybe something like

Is:A(“Drive Seat”) then

2 Likes

Yeah its possible, it just depends on how you have the game set up. One way is to get all the descendants of the game and loop through them and have them run the same thing if they are a seat, or in this instance, I believe you are using “VehicleSeat”.

for _, item in pairs(game:GetDescendants()) do
   if item:IsA("VehicleSeat") then
    item:GetPropertyChangedSignal("Occupant"):Connect(function(player) 
	if item.Occupant and ( item.Occupant == game.Players.LocalPlayer.Character.Humanoid ) then
		starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
	else
		starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
	end
       end)
end
end

Thank you very much!

All my RP games fail/die because people cause drive by shootings with guns in their vehicle and they can’t get shot back.

Really appreciated!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.