How would i make this GUI visible for one team only?

Hi.

I am trying to make it so if the ball touches the goal, a celebration gui appears, for the team that scored only. I have looked on the developer hub and found nothing. Here is the script:

local goal1 = workspace.goal1
local goal2 = workspace.goal2
local ball = workspace.TPS
local player = game.Players.LocalPlayer
local ball = game.Workspace.TPS 

ball.Touched:Connect(function(part)
	if part == goal1 then
		
		player.PlayerGui.EmotesGUI.Open.Visible = true
		wait (5)
		player.PlayerGui.EmotesGUI.Open.Visible = false
		player.PlayerGui.EmotesGUI.Animations.Visible = false
		
	elseif part == goal2 then
		
		player.PlayerGui.BarcaGUI.Frame.Visible = true
		wait (5)
		player.PlayerGui.BarcaGUI.Frame.Visible = false
		player.PlayerGui.EmotesGUI.Animations.Visible = false
	end

end)
1 Like

You can use player.Team for this

local goal1 = workspace.goal1
local goal2 = workspace.goal2
local ball = workspace.TPS
local player = game.Players.LocalPlayer
local ball = game.Workspace.TPS 

ball.Touched:Connect(function(part)
	if part == goal1 then
		
		if player.Team == "Team name" then
			player.PlayerGui.EmotesGUI.Open.Visible = true
			wait (5)
			player.PlayerGui.EmotesGUI.Open.Visible = false
			player.PlayerGui.EmotesGUI.Animations.Visible = false
		end
		

	elseif part == goal2 then
		
		if player.Team == "Team name" then
			player.PlayerGui.BarcaGUI.Frame.Visible = true
			wait (5)
			player.PlayerGui.BarcaGUI.Frame.Visible = false
			player.PlayerGui.EmotesGUI.Animations.Visible = false
		end
		
	end

end)
local goal1 = workspace.goal1
local goal2 = workspace.goal2
local ball = workspace.TPS
local player = game.Players.LocalPlayer
local ball = game.Workspace.TPS 

ball.Touched:Connect(function(part)
	if part == goal1 then
		if player.Team == "Team name" then
			player.PlayerGui.EmotesGUI.Open.Visible = true
			task.wait(5)
			player.PlayerGui.EmotesGUI.Open.Visible = false
			player.PlayerGui.EmotesGUI.Animations.Visible = false
		end
	elseif part == goal2 then
		if player.Team == "Team name" then
			player.PlayerGui.BarcaGUI.Frame.Visible = true
			task.wait(5)
			player.PlayerGui.BarcaGUI.Frame.Visible = false
			player.PlayerGui.EmotesGUI.Animations.Visible = false
		end
	end
end)

Just fixing the formatting of both scripts.

If player.TeamColor == Enum.BrickColor.Color then
      ui.Visible
end