What do you want to achieve?
I am trying to create a chat tag for whoever is #1 on the global leaderboard
What is the issue?
After testing my code in studio, it worked one time. After losing my #1 spot and reattaining it, the tag was gone. I could not reattain the tag.
local players = game:GetService("Players")
local chatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local tags = {
[0] = {TagText = "#1 Level", TagColor = Color3.fromRGB(15, 255, 219)},
}
chatService.SpeakerAdded:Connect(function(playerName)
local speaker = chatService:GetSpeaker(playerName)
local player = game.Players[playerName]
local leaderstats = player:WaitForChild("leaderstats")
player.Cash.Changed:Connect(function()
local firstPlace = game.Workspace.LB.LeaderboardUI.ScrollingFrame.Holder:FindFirstChild("LeaderboardFrame"):WaitForChild("Player").Text
local tagslist = {}
if tags[player.UserId] then
table.insert(tagslist, tags[player.UserId])
end
if player.Name == firstPlace then
table.insert(tagslist, {TagText = "#1 Level", TagColor = Color3.fromRGB(255, 234, 0)})
end
speaker:SetExtraData("Tags", tagslist)
end)
end)