Where in the chat system can you mess with when players chat and how to make certain players not see it

Hey, I’m making a social deduction game, ill get to the point, I have a value in the player, I’m just trying to make it so that whenever a player chats, I need to intercept that and make it so only certain people can see what they said, I already forked the chat system, I just don’t know how to detect when a player chats and how to make the client seeing that not see it,

Aka, I need players who are “dead” to not see players who are “alive” chat etc, I’ve already made a post like this but no one could really help.

2 Likes

Im currently making the same thing, I think I found a way for it to work. I’ll get back t you in a second, I’m still testing it

1 Like

For reference, please try to keep things in one thread. You could add more details or test attempts to your first thread as opposed to making a new one due to lack of helpful posts.

You can do this without forking the chat but you do have to make the system yourself, it’s not something you can easily configure in the default chat script without potentially breaking something or facing unintended consequences.

The idea is as follows:

I made a similar system in the past but it wasn’t a mutual chatting feature like this rather it was a complete exclusion feature, shadow banning. What it did was prevent a shadow banned user’s chats from being replicated to anyone else but they would still see their chats as normal.

1 Like

Hmm, Okay I might use this, I’d prefer do it with the forked chat system rather than manually send all their messages whenever they try to send a message, but I guess we’ll see what I decide on thanks though this helps

Thank you, please let me know when it’s ready I’d love to try whatever you’re working on

2 Likes

The point is: you don’t need to and shouldn’t fork it. Forking is only necessary in cases where support for your use case does not come out of the box or if it’s impossible to commit changes without forking. Either way you will still require a similar flow and it’s better to choose something that isn’t clunkier.

The Lua Chat System is highly customisable enough that the actual cases where you need to fork are much rarer. The suggestion I pitched simply changes the control of messaging sending from the ChatService to you by calling API in order to only send messages to players who are eligible to see the message while not sending it at all to those who aren’t.

I made this, It’s a bit janky but It works in my testing so far:
Just copy the thing I made here:
Capture2
create a module script named playerstatuscheck as shown above, then paste the code i made down below in it. You will have to edit it to work with your role system though
Make sure insertdefaultmodules is a bool value with the value set to true

local module = {}
local function Run(ChatService)
	local function ProcessMessage(speakerName, message, channelName)
		local speaker = ChatService:GetSpeaker(speakerName)
		local channel = ChatService:GetChannel(channelName)

		if not speaker then return false end
		if not channel then return false end
		if game.Players[speakerName]:FindFirstChild("Role") then -- Check if they have a role
			
				if game.Players[speakerName]:FindFirstChild("Role").Value == "dead" then -- is the role dead?
					for i, plr in pairs(game.Players:GetPlayers()) do -- this loop will only send the message to other dead players
						if plr:FindFirstChild("Role") then -- does the player were going to send the message to have a role?
							if plr:FindFirstChild("Role").Value == "dead" then -- are they dead? if so send them the message
								local speaker = ChatService:GetSpeaker(plr.Name)
								if speaker then
									speaker:SetExtraData("Tags",{{TagText = "Dead", TagColor = Color3.fromRGB(126, 126, 126)}})
									speaker:SendMessage(message, channelName, speakerName, message.ExtraData)
								end
							end
						else -- they have no role (there in the lobby), send the message
							local speaker = ChatService:GetSpeaker(plr.Name)
							if speaker then
								speaker:SetExtraData("Tags",{{TagText = "Dead", TagColor = Color3.fromRGB(126, 126, 126)}})
								speaker:SendMessage(message, channelName, speakerName, message.ExtraData)
							end
						end
					end
				
					
				else -- they must be alive if there role does not  = dead
				
					for i, plr in pairs(game.Players:GetPlayers()) do -- send the message to ALL players even dead ones
						local speaker = ChatService:GetSpeaker(plr.Name)
						if speaker then
							speaker:SetExtraData("Tags",{{TagText = "Alive", TagColor = Color3.fromRGB(57, 255, 63)}})
							speaker:SendMessage(message, channelName, speakerName, message.ExtraData)
						end
							
					end
				end
			return true
		else -- they have no role, send the message to others without a role and dead players. not alive players
			for i, plr in pairs(game.Players:GetPlayers()) do -- this loop will only send the message to other dead players
				if plr:FindFirstChild("Role") then -- does the player were going to send the message to have a role?
					if plr:FindFirstChild("Role").Value == "dead" then -- are they dead? if so send them the message
						local speaker = ChatService:GetSpeaker(plr.Name)
						if speaker then
							speaker:SetExtraData("Tags",{{TagText = "Dead", TagColor = Color3.fromRGB(126, 126, 126)}})
							speaker:SendMessage(message, channelName, speakerName, message.ExtraData)
						end
					end
				else -- they have no role send it to palyers who also have no role or are dead
					local speaker = ChatService:GetSpeaker(plr.Name)
					if speaker then
						speaker:SetExtraData("Tags",{{TagText = "InLobby", TagColor = Color3.fromRGB(255, 0, 12)}})
						speaker:SendMessage(message, channelName, speakerName, message.ExtraData)
					end
				end
			end

		end
	
		return true
	end

	ChatService:RegisterProcessCommandsFunction("swallow_shadow_ban_chat", ProcessMessage)
end

return Run

1 Like

what i did i just copied the main chat script when i played and went to these 2 functions and checked if there alive with the main local player or not

image

just a simple fix if ur just wanting to not show the dead players message

if game.Players:FindFirstChild(messageData.FromSpeaker) then
		if game.Players[messageData.FromSpeaker].Character then
			if not  game.Players[messageData.FromSpeaker].Character:FindFirstChild("GameTag") and game.Players.LocalPlayer.Character:FindFirstChild("GameTag") then
				return
			end
		end
	end
3 Likes

Thank you very much, there are certain roles that can see both alive and dead, But I think I know how to make it so they can see both appreciate the help man, testing this now

1 Like

Thank you so much, this actually worked! and I was able to solve all the other issues I have with this. very simple fix this is what I was looking for ty so much

1 Like