You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to fix my script that hides a players backpack while seated.
What is the issue? Include screenshots / videos if possible!
The darn script wont work even though it looks like it’d work.
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.
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)
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