Hello, how can I make that only those who are in a specific teamName can execute this chat command and perform the functions that are seen?
In such a way that only if you are in a specific teamName you can execute the functionalities of the code that are seen and if you are not in that team then you cannot.
How could i do that?
Server Script:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(message)
for i,Player2 in pairs(Players:GetPlayers()) do
if message == '.' .. Player2.Name then
print("The player name is ..." .. Player2.Name)
end
end
end)
end)
Couldn’t you just check if the Player’s Team is equal to the if statement you’re trying to check? Then afterwards check if the message is equal to your command, but you may need to use string.sub though?
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(message)
if message == "some text here" then
if Player.TeamColor == BrickColor.new("team color here") then
--some code here (this will only be executed if the player is in the desired team)
end
end
end)
end)