Team only commands

Hi! I would like to make a team only command! It would be :gann. It would make a goverment announment.

I have no clue how to make it.

I have tryed the toolbox and found nothing.

Is there anyway to do this?

take a look at this devhub article that works fine and have a check for what team the Player.Chatted event is being fired from

https://developer.roblox.com/en-us/api-reference/event/Player/Chatted

local players = game:GetService("Players")
local teams = game:GetService("Teams")
local team = teams.Team --Example team.

players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(chat)
		if chat:lower():match("^:gann%s") then
			if player.Team == team then
				local announcement = chat:gsub("^%S+%s", "")
				local message = Instance.new("Message")
				message.Text = announcement
				message.Parent = workspace
				task.wait(0.25 * announcement:len())
				message:Destroy()
			end
		end
	end)
end)

https://developer.roblox.com/en-us/api-reference/class/Message

Message is deprecated so feel free to use a GuiObject instead.

where does the script go??? Serverscriptstorage?

Any service which server scripts can execute in (SSS, workspace etc.).

local players = game:GetService(“Players”)
local teams = game:GetService(“Teams”)
local team = test1 --Example team.

players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(chat)
if chat:lower():match("^:gann%s") then
if player.Team == team then
local announcement = chat:gsub("^%S+%s", “”)
local message = Instance.new(“Message”)
message.Text = announcement
message.Parent = workspace
task.wait(0.25 * announcement:len())
message:Destroy()
end
end
end)
end)

Did I do it right so far?

Also were do I put the ui for it