Hi, so I'm working on this custom chat gui to work with filteringenabled but I'm encountering a few issues. The first issue I'm encountering is the gui uses the / key to enable the player to chat. However when I press / it doesn't fire the CaptureFocus() event from the serverscript. Clicking the chatbox however does allow the player to change the text, but it doesn't change on the servers side. That's also the second issue I'm having, where changing the text on the gui doesn't show up on the server but only the client. Just to be sure, what I'm trying to make the gui do is when the player types "/" it allows them to change the text, then when they press enter it creates the chat. Any advice would be much appreciated!
Custom Chat Gui not working?
2 answers
Custom chat is with filtering is easy to do.
Have a remote event in workspace and name it PlayerChatted. Insert a script inside it and put this code into it:
script.Parent.OnServerEvent:connect(function(plr,msg)
script.Parent:FireAllClients(plr,msg)
end)
Now you need to make a local script inside your chat gui and do a code like this:
-- Client Sided
local mouse = player:GetMouse()
TextBox.FocusLost:connect(function(enterPressed)
if enterPressed == true then
game.Workspace.PlayerChatted:FireServer(TextBox.Text)
end
end)
mouse.KeyDown:connect(function(key)
if key == "/" then
TextBox:CaptureFocus()
end
end)
game.Workspace.PlayerChatted.OnClientEvent:connect(function(plr,msg)
--add your gui chat stuff in here
print(plr.." has said "..msg)
end)
Hopefully looking at this would let you see what you're doing wrong or how to make your system better. Obviously I didn't include all the gui stuff or fancy features, as you'll be able to do them on your own. If this still doesn't work, or you have future questions about filtering enabled, please ask me.
~ObscureEntity
PS: I wrote this code on the website so I didn't test it, but those are the fundamentals needed to create the system. Hopefully you can work it out from there.
Hai.I am using a method someone thought me but i still hope it helps
i assume the guis is created.
Now heres the code
ServerScriptService
local event = game:GetService('ReplicatedStorage'):WaitForChild('Chatted')
event.OnServerEvent:connect(function(player, nameColor, message, messageColor)
event:FireAllClients(player, nameColor, message, messageColor)
end)
ReplicatedStorage
Insert a RemoteEvent in RS
StarterGui
I assume the guis is created So now,Insert a local script into the guis
Put this code,Its long
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
local colors = {'Deep orange', 'Toothpaste', 'Lime green', 'Hot pink', 'Cyan'}--Change to your colors
math.randomseed(os.time())
math.random()
math.random()
math.random()
math.random()
local player = game.Players.LocalPlayer
local nameColor = BrickColor.new(colors[math.random(1, #colors)]).Color
local messageColor = BrickColor.new('Institutional white').Color
local messageBox = script.Parent:WaitForChild('name of frame'):FindFirstChild('Name of text box')
local UIS = game:GetService('UserInputService')
local event = game:GetService('ReplicatedStorage'):WaitForChild('Chatted')
if player.Name == 'Jeysea' then
nameColor = BrickColor.new('Really red').Color
end
function onInput(Input, GPE)
if GPE then return end
if Input.KeyCode == Enum.KeyCode.Slash then
messageBox:CaptureFocus()
end
end
function onFocus()
if messageBox.Text == 'Press \'/\' to type a message...' then
messageBox.Text = ''
end
end
function onFocusLost(EnterPressed)
if EnterPressed then
if messageBox.Text ~= '' then
event:FireServer(nameColor, messageBox.Text, messageColor)
messageBox.Text = 'Press \'/\' to type a message...'
else
messageBox.Text = 'Press \'/\' to type a message...'
end
else
if messageBox.Text == '' then
messageBox.Text = 'Press \'/\' to type a message...'
end
end
end
--player.Chatted:connect(function(message)
-- event:FireServer(nameColor, message, messageColor)
--end)
function addLine(message, Label)
local chatBox = script.Parent:FindFirstChild('Frame')
local newMessage = Instance.new('Frame', chatBox)
newMessage.Size = UDim2.new(1, -10, 0, 20)
newMessage.Position = UDim2.new(0, 5, 1, -25)
newMessage.BackgroundTransparency = 1
newMessage.ClipsDescendants = true
local lineMessage = ''
while Label.TextFits == false do
lineMessage = string.sub(message, -1) .. lineMessage
message = string.sub(message, 1, string.len(message) - 1)
Label.Text = message
end
for _, oldMessage in pairs (chatBox:GetChildren()) do
if oldMessage ~= newMessage then
oldMessage.Position = oldMessage.Position + UDim2.new(0, 0, 0, -newMessage.AbsoluteSize.Y + 5)
end
end
local messageLabel = Instance.new('TextLabel', newMessage)
messageLabel.BackgroundTransparency = 1
messageLabel.Font = 'SourceSansBold'
messageLabel.TextColor3 = messageColor
messageLabel.FontSize = 'Size18'
messageLabel.TextXAlignment = 'Left'
messageLabel.Text = lineMessage
messageLabel.Size = UDim2.new(1, -10, 0, 20)
messageLabel.TextStrokeTransparency = 0.6
messageLabel.Position = UDim2.new(0, 5, 0, 0)
local LineTag = Instance.new('StringValue', messageLabel.Parent)
LineTag.Name = 'LineTag'
local LineTag2 =Instance.new('StringValue', Label.Parent)
LineTag2.Name = 'LineTag'
if messageLabel.TextFits ~= true then
addLine(lineMessage, messageLabel)
print('addingling')
else
for _, oldMessage in pairs (chatBox:GetChildren()) do
if not oldMessage:FindFirstChild('LineTag') then
oldMessage.Position = oldMessage.Position + UDim2.new(0, 0, 0, -newMessage.AbsoluteSize.Y + 5)
end
end
end
LineTag:Destroy()
LineTag2:Destroy()
end
function onEvent(sender, nameColor, message, messageColor)
local chatBox = script.Parent:FindFirstChild('Frame')
local newMessage = Instance.new('Frame', chatBox)
newMessage.Size = UDim2.new(1, -10, 0, 20)
newMessage.Position = UDim2.new(0, 5, 1, -25)
newMessage.BackgroundTransparency = 1
newMessage.ClipsDescendants = true
local nameLabel = Instance.new('TextLabel', newMessage)
nameLabel.BackgroundTransparency = 1
nameLabel.Font = 'SourceSansBold'
nameLabel.TextColor3 = nameColor
nameLabel.FontSize = 'Size18'
nameLabel.TextXAlignment = 'Left'
nameLabel.Text = '[' .. sender.Name .. ']:'
nameLabel.Size = UDim2.new(0, nameLabel.TextBounds.X + 5, 0, 20)
nameLabel.TextStrokeTransparency = 0.6
local messageLabel = Instance.new('TextLabel', newMessage)
messageLabel.BackgroundTransparency = 1
messageLabel.Font = 'SourceSansBold'
messageLabel.TextColor3 = messageColor
messageLabel.FontSize = 'Size18'
messageLabel.TextXAlignment = 'Left'
messageLabel.Text = message
messageLabel.Size = UDim2.new(1, -nameLabel.AbsoluteSize.X, 0, 20)
messageLabel.Position = nameLabel.Position + UDim2.new(0, nameLabel.AbsoluteSize.X, 0, 0)
messageLabel.TextStrokeTransparency = 0.6
if messageLabel.TextFits ~= true then
addLine(message, messageLabel)
else
for _, oldMessage in pairs (chatBox:GetChildren()) do
if oldMessage ~= newMessage then
oldMessage.Position = oldMessage.Position + UDim2.new(0, 0, 0, -newMessage.AbsoluteSize.Y + 5)
end
end
end
end
UIS.InputBegan:connect(onInput)
event.OnClientEvent:connect(onEvent)
messageBox.Focused:connect(onFocus)
messageBox.FocusLost:connect(onFocusLost)
I hope this helped,if anything happens or goes wrong,Comment down.
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
I tried it, and I was able to get the / key to work. However when it does the chat it says the textbox's orginal text; "Type "/" to chat.", Any idea I can it make so the text updates on the serverside? I'll continue working on it, but I'm still open for any advice!
Also, I have the default Roblox chat gui disabled for both classic and bubble chat because the gui creates custom chat boxes. Right now the only problem I'm having is making it so when the player changes the text on the textbox it doesn't change on the servers side.
There's nothing you need to do for server sided besides firing all clients the message. I'll make you a model for you to see how to make the stuff and I'll pm you it. (Give me 3 hours because Im in school right now.)
http://www.roblox.com/item.aspx?id=345938925 There you go. Make sure you put the gui in starter gui and playerchatted in workspace and that should work for you :).