Trying to edit the ChatService with Group roles

So, I’m trying to make chat tags for certain roles in the group which I tried doing here:

local Players = game:GetService('Players')
local ServerScriptService = game:GetService('ServerScriptService')
local ServerStorage = game:GetService("ServerStorage")

local Configurations = require(ServerStorage.Configurations)

local ChatService = require(ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

ChatService.SpeakerAdded:Connect(function(Player)
	local Speaker = ChatService:GetSpeaker(Player)
	local rank = Player:GetRankInGroup(Configurations.GROUP_ID)
	if (rank == 255) then
		Speaker:SetExtraData('NameColor', Color3.fromRGB(209, 193, 97))
		Speaker:SetExtraData('ChatColor', Color3.fromRGB(178, 248, 229))
		Speaker:SetExtraData('Tags', {{TagText = 'OWNER', TagColor = Color3.fromRGB(189, 83, 83)}})
	end
end)

But the error is on the GetRankInGroup, I’m pretty sure it’s a problem with attempting to call a nil val with what im using as a Player instance? I’m not too sure.

Player is a string that SpeakerAdded returns, which is the name of the speaker that has been added, If you want to get the player, what I first recommend is renaming the parameter since it can be confusing, and to do

game:GetService("Players"):FindFirstChild(SpeakerName)

Where SpeakerName is the return of SpeakerAdded

ChatService.SpeakerAdded:Connect(function(name)
	local Speaker = ChatService:GetSpeaker(name)
	local Player = Players:FindFirstChild(name)
	local rank = Player:GetRankInGroup(Configurations.GROUP_ID)
	if (rank == 255) then
		Speaker:SetExtraData('NameColor', Color3.fromRGB(209, 193, 97))
		Speaker:SetExtraData('ChatColor', Color3.fromRGB(178, 248, 229))
		Speaker:SetExtraData('Tags', {{TagText = 'OWNER', TagColor = Color3.fromRGB(189, 83, 83)}})
	end
end)

Oh thank you so much for your help, it works perfectly.

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!

1 Like