Group Chat Script is a little werid

So I was trying to make a group chat this where if your in the group you get a tag.

But theres 2 problems

1.If your not is the group then your tag is Guest but I want you to have no tag (Check By inserting into a game and chat you will see)
2.I want to change Tag Color and Chat color

local players = game:GetService(“Players”)
local serverScriptService = game:GetService(“ServerScriptService”)
local chatService = require(serverScriptService:WaitForChild(“ChatServiceRunner”):WaitForChild(“ChatService”))

chatService.SpeakerAdded:Connect(function(player)
local speaker = chatService:GetSpeaker(player)
players[player]:IsInGroup(9257320)
speaker:SetExtraData(“Tags”,{{TagText = players[player]:GetRoleInGroup(9257320)}})
end)

I have a few suggestions for how to fix it:

If you haven’t already I would strongly suggest thoroughly reading the documentation of the chat system to get a good understanding of how it works.

I wouldn’t suggest requiring the chat service like that I think what you should do is read over this part of the documentation then continue from there:

I wouldn’t suggest having the code think that the speaker added is always going to be a player connected speaker because it can be bot.

If I remember correctly that function does accept more than just the text I think it except colors too.

Try doing something like if players[player]:IsInGroup(9257320) then. That should make it not show up when the person isn’t in the group.

Hope that helps. Feel free to ask any questions if you have any.

Sorry I am really bad at scripting could you put an example script or something.

Here you go I just took what you made then remade it

local function Run(chatService)
local tagColor = Color3.fromRGB(255, 255, 255)
chatService.SpeakerAdded:Connect(function(speakerName)
local speaker = chatService:GetSpeaker(speakerName)
local player = chatService:GetPlayer()
if player and player:IsInGroup(9257320) then
speaker:SetExtraData(“Tags”,{{TagText = player:GetRoleInGroup(9257320), TagColor = tagColor}})
end)
end
end
 
return Run

(Put that code in a ModuleScript inside of the game.Chat.ChatModules folder)

It does not work in my game. Do I have to copy and paste ChatMoudles folder in chat or play and them add script?

This should answer your question. If it still doesn’t work I’m going to need you to show me the error that you’re getting when you try to run it.


(I don’t think you have to disable the Chat.LoadDefaultChat as I haven’t ran into any problems when I haven’t disabled it.)

still dont work could you make a script that uses SeverScriptStorage Like my old one.

I’m going to try it out for myself and see if I can figure out what the problem is. I’m still new to coding as I haven’t really been doing it for that long (only like a year or two).

1 Like

Use my group ID to see the problem with the guest thing

That isn’t specific to your group that’s just the name of your rank when you are not in a group.

Yeah I know but Still you can use it for convienence

My bad, it looks like I made a few mistakes that were making the code give errors. The code below should work as I actually verified it myself.

local function Run(chatService)
	local tagColor = Color3.fromRGB(255, 255, 255)
	chatService.SpeakerAdded:Connect(function(speakerName)
		local speaker = chatService:GetSpeaker(speakerName)
		local player = speaker:GetPlayer()
		if player and player:IsInGroup(9257320) then
			speaker:SetExtraData("Tags",{{TagText = player:GetRoleInGroup(9257320), TagColor = tagColor}})
		end
	end)
end

return Run

Nice one problem is that It doesnt Change your text color

You mean like the text color of your name? I can have it set that too if you want.

No Like Bloxburg Example

See how primum member had red text.

Here you go

local function Run(chatService)
	local tagColor = Color3.fromRGB(255, 255, 255)
	local chatTextColor = Color3.fromRGB(255, 255, 255)
	chatService.SpeakerAdded:Connect(function(speakerName)
		local speaker = chatService:GetSpeaker(speakerName)
		local player = speaker:GetPlayer()
		if player and player:IsInGroup(9257320) then
			speaker:SetExtraData("Tags",{{TagText = player:GetRoleInGroup(9257320), TagColor = tagColor}})
  			speaker:SetExtraData("ChatColor", chatTextColor)
		end
	end)
end

return Run
1 Like

Where would I put this? It worked the way I put it in one game. Now that way isnt working. Also is it script or what?

First follow these steps but skip the last one.

Then after you’re done doing that there should be a folder called ChatModules, go ahead and insert a module script into that. (Also the name of it doesn’t matter.)

Then once you’ve inserted it, open it up and replace what is inside of it with the code that I gave you. After that you should be done.

1 Like

This just disabled chat. Could you link me the post I dont exactly know which ones to copy? The way I did it in my old game does not work in this game.

Did you disable Chat.LoadDefaultChat? If so that is probably why the chat isn’t appearing.

If it isn’t disabled then I don’t think I’m going to be able to help with that. I’m pretty certain the instructions that I gave should have worked and I can’t think of any other reason why they wouldn’t have. I tested those instructions in a newly loaded baseplate before I replied with them and I didn’t find any issues.