What i want to achieve is that when you typ something in chat, It looks like
[amountOfBadgesOwnedByPlr][GroupRank] plr.Name
It keeps giving the error that the player doesn’t exist when looping throught the amount of badges the plr has.
If anyone knows what i am doing wrong, You are a life safer.
Module –
local module = {}
module.BadgeIDs = {
[1] = {
ID = 2124972910;
Colour = ColorSequence.new(Color3.new(0.329412, 0.25098, 0.333333),Color3.new(1, 0.666667, 1));
};
[2] = {
ID = 2124972899;
}
}
return module
Another Module Script –
local BadgeService = game:GetService("BadgeService")
local PlayerService = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
-- // Modules
local Ranks = require(ReplicatedStorage.Modules["Ranks-Badges"].Ranks)
local chatService = require(ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
-- // Variables
local groupId = 7628430
-- // Table
local module = {}
-- // Functions
function module:CreateChatTags(plr)
local speaker = chatService:GetSpeaker(plr)
if PlayerService[plr]:IsInGroup(groupId) then
local PlayerRank = PlayerService[plr]:GetRoleInGroup(groupId)
for _, v in ipairs(Ranks.BadgeIDs) do
if BadgeService:UserHasBadgeAsync(plr.UserId, v.ID) then
print(1)
local TestTable = {
{TagText = v.ID, TagColor = v.Colour};
{TagText = PlayerRank, TagColor = Ranks.GroupRanks()[PlayerRank]}
}
speaker:SetExtraData('NameColor', Color3.fromRGB(255, 255, 255))
speaker:SetExtraData("Tags", TestTable)
else
speaker:SetExtraData('NameColor', Color3.fromRGB(255, 255, 255))
speaker:SetExtraData('Tags', {{TagText = "Guest", TagColor = Color3.fromRGB(255, 255, 127)}})
end
end
end
end
return module
Server Script –
--// Services
local PlayersService = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
--// Requires
local ChatTags = require(ReplicatedStorage.Modules.ChatTags["Chat Tags"])
local chatService = require(ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
--// Functions
chatService.SpeakerAdded:Connect(function(plr)
ChatTags:CreateChatTags(plr)
end)