While on a specific team, for this instance let’s say the Team Color is Black.
I want a StarterGUI called MorphSelection to not appear. That GUI and that GUI only. I’ve tried to script this myself, however, I cannot seem to do it. So I figured someone here may be able to assist me in this task.
Sorry for the terrible description. I was never a creative writer.
local teamBlack = -- get team black
local gui = -- get gui
game.Players.PlayerAdded:Connect(function(plr)
if plr.TeamColor == teamBlack.TeamColor then
gui.Enabled = false
end
end)
That should work I did not test it though. Just store the team in variable teamBlack and the gui in variable gui.
Do I just copy paste exactly that into a Script and place it inside ServerScriptService? I’m only starting to learn scripting because I have a lot of time due to Lockdown.
You can loops through the players and their teams,
for i,Player in pairs(game.Players:GetPlayers()) do
if Player.Team ~= game.Teams.TeamName then
Player:FindFirstChild("PlayerGui").MorphSelection:Destroy()
end
end
local teamBlack = game.Teams:WaitForChild("TeamName")
game.Players.PlayerAdded:Connect(function(plr)
if plr.TeamColor == teamBlack.TeamColor then
local gui = plr.PlayerGui:WaitForChild("TeamName")
gui.Enabled = false
end
end)
Use that it should fix it. That is my fault player was not defined until the function so you have to add that part into the function!
local teamBlack = – get team black
local gui = – get gui
game.Players.PlayerAdded:Connect(function(plr)
if plr.Team == teamBlack then
gui.Enabled = false
end
plr:GetPropertyChangedSignal("Team"):Connect(function()
if plr.Team == teamBlack then
gui.Enabled = false
end
end)
end)
Just to make it still checking if player’s team isn’t the black one. The code you made checked it just when the player joined, if the player would change his team, then it wouldn’t disable the GUI for him.
local teamBlack = game.Teams:WaitForChild("Arrested")
local gui = player.PlayerGui:WaitForChild("MorphSelection")
game.Players.PlayerAdded:Connect(function(plr)
local gui = plr.PlayerGui:WaitForChild("MorphSelection")
if plr.Team == teamBlack then
gui.Enabled = false
end
plr:GetPropertyChangedSignal("Team"):Connect(function()
if plr.Team == teamBlack then
gui.Enabled = false
end
end)
end)
Use this code and it will work right, as you want it to be working
local teamBlack = game.Teams:WaitForChild("Arrested")
game.Players.PlayerAdded:Connect(function(plr)
if plr.Team == teamBlack then
local gui = plr.PlayerGui:WaitForChild("MorphSelection")
gui.Enabled = false
end
plr:GetPropertyChangedSignal("Team"):Connect(function()
if plr.Team == teamBlack then
local gui = plr.PlayerGui:WaitForChild("MorphSelection")
gui.Enabled = false
end
end)
end)