✓ Accepted answer
You'll gonna need to use a RemoteEvent for this. Make sure you have a Script in ServerScriptService, a LocalScript in StarterGui, and a RemoteEvent named EnableBackpack in ReplicatedStorage.
To detect if a play joins a Team, you use Team.PlayerAdded and Team.PlayerRemoved when a player leaves the Team.
Script in ServerScriptService:
local Teams = game:GetService("Teams")
local CitizenTeam = Teams.Citizen
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EnableBackpack = ReplicatedStorage.EnableBackpack
CitizenTeam.PlayerAdded:Connect(function(player)
EnableBackpack:FireClient(player, false)
end)
CitizenTeam.PlayerRemoved:Connect(function(player)
pcall(function()
EnableBackpack:FireClient(player, true)
end)
end)
LocalScript in StarterGui:
local StarterGui = game:GetService("StarterGui")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EnableBackpack = ReplicatedStorage:WaitForChild("EnableBackpack")
EnableBackpack.OnClientEvent:Connect(function(enabled)
local success
repeat
success = pcall(function()
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, enabled)
end)
until success
end)
1 comment
It works thanks!!