I have a script for chat tags but it randomly stopped working >:( (used to work perfectly fine)
Sometimes when I join, there are like 1-2 people that still get the tag but almost everyone else doesn’t have it. It seems to be showing more in studio now.
Error: attempt to index nil with ‘SetExtraData’
local cache = require(game.ServerScriptService.ProfileCacher)
rankInfo = {
['MVP_PLUS'] = {
TAG = { {TagText = "MVP+", TagColor = Color3.fromRGB(255, 170, 0)} },
CHATCOLOR = Color3.fromRGB(255, 170, 0),
NAMECOLOR = Color3.fromRGB(255, 170, 0),
},
['MVP'] = {
TAG = { {TagText = "MVP", TagColor = Color3.fromRGB(85, 255, 255)} },
CHATCOLOR = Color3.fromRGB(85, 255, 255),
NAMECOLOR = Color3.fromRGB(85, 255, 255),
},
['VIP'] = {
TAG = { {TagText = "VIP", TagColor = Color3.fromRGB(85, 255, 0)} },
CHATCOLOR = Color3.fromRGB(85, 255, 0),
NAMECOLOR = Color3.fromRGB(85, 255, 0),
},
['NON'] = {
CHATCOLOR = Color3.fromRGB(188, 188, 188),
NAMECOLOR = Color3.fromRGB(188, 188, 188),
},
}
game.Players.PlayerAdded:Connect(function(player)
local profile = cache[player]
if profile == nil then
repeat
profile = cache[player]
wait(.025)
until profile ~= nil
end
local ChatServiceRunner = game.ServerScriptService:WaitForChild("ChatServiceRunner", 5)
local ChatService = require(ChatServiceRunner:WaitForChild('ChatService'))
local Speaker = ChatService:GetSpeaker(tostring(player.Name))
if profile and profile.Data.Ranks.MVP_PLUS == true then
Speaker:SetExtraData("Tags", rankInfo.MVP_PLUS.TAG)
Speaker:SetExtraData("ChatColor", rankInfo.MVP_PLUS.CHATCOLOR)
Speaker:SetExtraData("NameColor", rankInfo.MVP_PLUS.NAMECOLOR)
elseif profile and profile.Data.Ranks.MVP == true then
Speaker:SetExtraData("Tags", rankInfo.MVP.TAG)
Speaker:SetExtraData("ChatColor", rankInfo.MVP.CHATCOLOR)
Speaker:SetExtraData("NameColor", rankInfo.MVP.NAMECOLOR)
elseif profile and profile.Data.Ranks.VIP == true then
Speaker:SetExtraData("Tags", rankInfo.VIP.TAG)
Speaker:SetExtraData("ChatColor", rankInfo.VIP.CHATCOLOR)
Speaker:SetExtraData("NameColor", rankInfo.VIP.NAMECOLOR)
else
Speaker:SetExtraData("ChatColor", rankInfo.NON.CHATCOLOR)
Speaker:SetExtraData("NameColor", rankInfo.NON.NAMECOLOR)
end
end)