How to script a microphone (chat) screen?

Hi all!

I make events on ROBLOX, and I want to script a microphone screen. I want it to work so a player will equip a microphone tool. Then whatever they type in chat is also displayed on a screen (surface gui text label).

I know how to code basic tools and surface gui’s, but I have no clue how to go about coding the chat system and linking it all together. Any help would be appreciated very much!

Thanks

Basically you just to know these few things.

If the tool is equipped then,
Once the player chats do →
Display the message they sent.

Thats the very basics.

You are going to need to use:

Player.Chatted:Connect(function(MESSAGE)

to get the message

2 Likes

Here’s a pseudo-code sample of how you might do this:

Player.Chatted:Connect(function(msg) -- Whenever the player sends a message
    local tool = Player.Character:FindFirstChildWhichIsA("tool") -- Check if the player has the tool equipped
    if not tool or not tool.IdentifyingProperty == "Microphone" then -- If the tool does not exist or it isn't specifically the microphone
        return
    end
    display(msg) -- Display the messages if these conditions aren't false

-- Sorry for the messy concept, it's just what I had off the top of my head
end)

Of course, you’d need a LocalScript that runs when the remote event is fired and displays the message on the Player’s screen.

I’ve fixed the script and its working!

Here it is for anyone who wants it!

local ChatService = game:GetService("Chat")

local microphone = script.Parent
local screens = workspace["Microphone Screens | LG rblx."].Screens:GetChildren()
local Players = game.Players

Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(MESSAGE)
		for i,v in pairs(screens) do
			v.SurfaceGui.Frame.Chat.Text = MESSAGE
		end

	end)
end)
1 Like

I’ve just realised that this script isn’t the final script, as whatever a user says will appear regardless of tool equipped

You can check if a player has a tool equipped if the tool instance is a child of the player’s character model. You can do this with Player.Character:FindFirstChildWhichIsA("Tool").