UI only visible by one team

Hello, the script (below) is supposed to display the emergency messages that the players send, to the police players (so in the police team). Except that when a civilian sends a message, it is not displayed for the police players. However, if the player who sent the message becomes a policeman and sends a message back, it works. How to make the sent message appear for all the police team and not only for the player who sent the message?

script :

local players = game:GetService("Players")
local player = players.LocalPlayer
local Teams = game:GetService("Teams")
local PoliceTeam = Teams.Police

script.Parent.Parent.SendButton.MouseButton1Click:Connect(function()
	if player.TeamColor == PoliceTeam.TeamColor then
		player:WaitForChild("PlayerGui").EmergencyCalls.PoliceFrame.Visible = true
		player:WaitForChild("PlayerGui").EmergencyCalls.PoliceFrame.CallText.Text = script.Parent.Parent.TextBox.Text
		wait(10)
		player:WaitForChild("PlayerGui").EmergencyCalls.PoliceFrame.Visible = false
	end
end)

how I built this :
image

thanks in advance and sorry, I don’t know how to code so I’m having trouble :sweat_smile:

Use a remote event. On the server display the message for all team members.

As I said I don’t know much about this, is there an easier way to stay on my localScript of the send button? :sweat_smile:

Use player.Team instead of TeamColor

local players = game:GetService("Players")
local player = players.LocalPlayer
local Teams = game:GetService("Teams")
local PoliceTeam = Teams.Police

script.Parent.Parent.SendButton.MouseButton1Click:Connect(function()
	if player.Team == PoliceTeam then
		player:WaitForChild("PlayerGui").EmergencyCalls.PoliceFrame.Visible = true
		player:WaitForChild("PlayerGui").EmergencyCalls.PoliceFrame.CallText.Text = script.Parent.Parent.TextBox.Text
		wait(10)
		player:WaitForChild("PlayerGui").EmergencyCalls.PoliceFrame.Visible = false
	end
end)

It does not work, always the same problem of emergency messages that are displayed only for the person who sent it (if he is a police officer)

If you think it’s the best solution I’ll go with that but I confess I personally don’t know how to do what you advise, could you show me? If not, don’t worry, I’ll wait for someone else to help me :slight_smile: good evening or morning…

1 Like

Hi! your script works but it’s not what I want to do. come here because I explained it better and I’ve made some progress on the code since please: How to display a UI for a Team only