Conceptually, can I make a chat tag that displays a player's individual leaderboard score AND team? E.g.; [2 eliminations] [Red] [ChirpPerson]: Example text.
Here is the chat tag script I'm currently using that currently displays only a player's team, would I have to rewrite it to tailor it better to my vision or is my vision compatible with this script?
Would I achieve making a chat tag with a player's score by setting up another function recognizing the local player by identifying the player as the speaker and then accessing the local player's leaderstats? I'm still very new to scripting and I'm trying my best to understand and articulate everything, I admittedly may just need to take a step back and work it another way. I ask that you please just help guide me in the right direction.
The script is located in ServerScriptService.
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local Teams = game:GetService("Teams")
local TeamList = Teams:GetTeams()
local ChatServiceRunner = ServerScriptService:WaitForChild("ChatServiceRunner")
local Speakers = ChatService:GetSpeakerList()
local TeamTags = {
["Red"] = {
ChatColor = BrickColor.new("Institutional white").Color,
NameColor = BrickColor.new("Institutional white").Color,
Font = Enum.Font.SourceSansBold,
TextSize = 18,
Tags = {
{
TagText = "Score Placeholder",
TagColor = BrickColor.new("New Yeller").Color
},
{
TagText = "Red",
TagColor = BrickColor.new("Bright red").Color
},
},
},
["Blue"] = {
ChatColor = BrickColor.new("Institutional white").Color,
NameColor = BrickColor.new("Institutional white").Color,
Font = Enum.Font.SourceSansBold,
TextSize = 18,
Tags = {
{
TagText = "Score Placeholder",
TagColor = BrickColor.new("New Yeller").Color
},
{
TagText = "Blue",
TagColor = BrickColor.new("Bright blue").Color
},
},
},
local ClearTags = {
["Neutral"] = {
ChatColor = BrickColor.new("White").Color,
--NameColor = BrickColor.new("White").Color,
Font = Enum.Font.SourceSansBold,
TextSize = 18,
Tags = {}
},
}
local function SetChatTags(SpeakerName)
local speaker = ChatService:GetSpeaker(SpeakerName)
local player = speaker:GetPlayer()
if player and player.Team ~= nil then
local TeamCheck = TeamTags[player.Team.Name]
if TeamCheck then
for key, value in pairs(TeamCheck) do
speaker:SetExtraData(key, value)
print("TeamTag set")
end
elseif not TeamCheck then
print(player.Name.." is on a Team that has no Chat Tag in the TeamTags list")
for key, value in pairs(ClearTags["Neutral"]) do
speaker:SetExtraData(key, value)
print("Tags have been cleared")
end
end
end
end
ChatService.SpeakerAdded:Connect(function(SpeakerName)
SetChatTags(SpeakerName)
local speaker = ChatService:GetSpeaker(SpeakerName)
local player = speaker:GetPlayer()
local PlayerTeam = player.Team
if player then
player:GetPropertyChangedSignal("Neutral"):Connect(function()
if player.Neutral == true then
for key, value in pairs(ClearTags["Neutral"]) do
speaker:SetExtraData(key, value)
print("Tags have been cleared")
end
end
end)
for i,Team in pairs(TeamList) do
Team.PlayerAdded:Connect(function()
if PlayerTeam then
warn("Activing SetChatTags from Team Change")
SetChatTags(SpeakerName)
end
end)
end
end
end)
for i,SpeakerName in pairs(Speakers) do
SetChatTags(SpeakerName)
end
