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!
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.
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)
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").