One is a local script, and the other is a script in ServerScriptService that's supposed to give players a certain GUI based on what team they're on. The GUI script works when the Local Script isn't in the game, but that Local Script is needed for the game to work properly. Help needed.
local player = game.Players.LocalPlayer
player.CharacterAdded:connect(function(character)
player.PlayerGui:ClearAllChildren()
local scripts = character:WaitForChild("Scripts")
for i, localscript in pairs(scripts:GetChildren()) do
if localscript:IsA("LocalScript") then
if not localscript.Disabled then
localscript.Disabled = true
localscript.Disabled = false
end
end
end
for i, gui in pairs(game.ReplicatedStorage.StarterGui:GetChildren()) do
gui:Clone().Parent = player.PlayerGui
end
end)
local screengui = game.ServerStorage["Class GUI"] --[[ The location of the gui you wish to clone ]]
local screenguib = game.ServerStorage["Class GUI2"]
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
if player.TeamColor == game.Teams["Red Forces"].TeamColor then --[[ This is more reliable, change the 'Bright red Team' to your team's name. ]]
if player.PlayerGui then
screengui:clone().Parent = player.PlayerGui
end
elseif player.TeamColor == game.Teams["Green Forces"].TeamColor then
if player.PlayerGui then
screenguib:clone().Parent = player.PlayerGui
end
end
end)
end)
