Hey @CanadianAviatorRBX , sorry for the late response! You can create a table in a server script and fill it will the userids of the staff members you want
local staffTable = {}
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
if table.find(staffTable, player.UserId) then
local Gui = player.PlayerGui:FindFirstChild("Gui Name Here")
if Gui then
if not Gui.Enabled then
Gui.Enabled = true
end
end
end
end)
It’s a little harder to type since I’m on my phone
I most likely won’t be able to respond for the next few hours
Ok Thanks! Is there any way to make it team specific and not player id specific? Because I dont wanna shut down the game every time I add a staff member
local Teams = game:GetService("Teams")
local Players = game:GetService("Players")
local StaffTeam = Teams:FindFirstChild("Team Name")
Player.PlayerAdded:Connect(function(player)
if StaffTeam then
if player.Team == StaffTeam then
local Gui = player.PlayerGui:FindFirstChild("Gui Name Here")
if Gui then
if not Gui.Enabled then
Gui.Enabled = true
end
end
end
end
end)
Thanks! You’ve been really helpful. One last question. How would I go about un-enabling the gui when the player leaves the team? Would I basically just reverse the code you gave me?
or an alternative would be to create a localscript that fires a RemoteEvent, but that’s up to you
Localscript:
local Remote = game.ReplicatedStorage:WaitForChild("Event Name")
local Player = game:GetService("Players").LocalPlayer
Player:GetPropertyChangedSignal("Team"):Connect(function()
Remote:FireServer()
end)
ServerScript:
local Remote = game.ReplicatedStorage:WaitForChild("Event Name")
local Teams = game:GetService("Teams")
local StaffTeam = Teams:FindFirstChild("Team Name")
Remote.OnServerEvent:Connect(function(player)
local Team = player.Team
if StaffTeam then
if StaffTeam == Team then
local Gui = player.PlayerGui:FindFirstChild("Gui Name")
if Gui then
Gui.Enabled = not Gui.Enabled
end
end
end
end)