Hiding backpack gui

Im making so the backpack gui hides when a players touchs a part. But im trying to make it so only the player who is touching the part that there backpack is hidden.
Its in a local Script

local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local human = char:FindFirstChild("Humanoid")

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

game.Workspace.NoSir.Touched:Connect(function(player)
	if player and player.Parent and player.Parent:FindFirstChild("Humanoid") then
		game.StarterGui:SetCoreGuiEnabled(
			Enum.CoreGuiType.Backpack, false
		)
	else
		return
	end
end)

game.Workspace.NoSir.TouchEnded:Connect(function(player)
	if player and player.Parent and player.Parent:FindFirstChild("Humanoid") then
		game.StarterGui:SetCoreGuiEnabled(
			Enum.CoreGuiType.Backpack, true
		)
	end
end)

1 Like

Hi Mate, what is happening at the moment when you run this setup does it not function at all? Is there any errors in the output :+1:

1 Like

It runs fine but it makes it so if one player touches the part then everyones backpack gui is hidden. All I want is only the player who is touching the part there backpack gui is hidden

1 Like

Ok cool yeah this command

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

As far as i know if it is in a server script or local scipt will effect all players.

do you have a cusotmer backpack you could control for the local player

1 Like

What is ame? and where do I put this in my script?

no mate sorry it was a typo i dont believe you can control the core backpack for one player as far as i know. best to use a customer backpack control it in a local script.

1 Like

you dont check if the localplayer is touching the part so it disables for all players when touched by a character

part.Touched:Connect(function(hit)
       local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
       if Player and Player == LocalPlayer then
            print("localpalyer touched the part")
      end
end)
1 Like