Uh... I've watched a video from @ScriptGuider on how to make a Custom Chat. I really don't understand very well a few parts of what he wrote, so I would appreciate an explanation of some bits of code that I'll indicate. As I want to learn on how to FilteringEnabled, I understand the structure in general on how it works, but there is parts that I don't understand, so I hope I get some more understanding of this after this post!
ServerChat > ServerScriptService
--\\ Services
local RepStorage = game:GetService'ReplicatedStorage'
--\\ Remotes
local ChatEvent = RepStorage:WaitForChild'ChatRemote'
--\\ Remote event
ChatEvent.OnServerEvent:connect(function(Client, Request, Value)
Request = Request:lower()
if Request == "chat" then
ChatEvent:FireAllClients("chat", Value, Client.Name)
end
end)
ClientChat > StarterGui
--\\ Services
local RepStorage = game:GetService'ReplicatedStorage'
local Players = game:GetService'Players'
local StarterGui = game:GetService'StarterGui'
--\\ Remotes
local ChatEvent = RepStorage:WaitForChild'ChatRemote'
--\\ Client stuff
local Client = Players.LocalPlayer
local Mouse = Client:GetMouse()
--\\ GUIs
local Chatbar = script.Parent
local ChatFrame = Chatbar.Parent
--\\ Chat messages
local Chats = {} -- Why is this Chat table empty?
--\\ Push messages
local function PushMessages(Size) -- How does this argument identify himself as the Size of the GUI?
for i,v in pairs(Chats) do
v.Position = v.Position - UDim2.new(0,0,0,Size)
if v.Position.Y.Offset < -ChatFrame.AbsoluteSize.Y then
Chats[i] = nil
v:Destroy()
end
end
--\\ Create message
local function CreateMessage(Message, Speaker) -- What are the argument's utility here?
local Label = Instance.new("TextLabel")
Label.BackgroundTransparency = 1
Label.TextXAlignment = "Left"
Label.TextColor3 = Color3.new(1,1,1)
Label.Font = "ArialBold"
Label.FontSize = "Size18"
Label.Size = UDim2.new(1, 0, 0, 25)
Label.Position = UDim2.new(0, 0, 1, -25)
Label.Text = tostring(Speaker) .." : " ..Message
PushMessages(Label.Size.Y.Offset)
Chats[#Chats+1] = Label -- What does this line do?
Label.Parent = ChatFrame
end
Mouse.KeyDown:connect(function(Key)
if Key:byte() == 47 then
Chatbar:CaptureFocus() -- CaptureFocus() Is a function of the Mouse?
end
end)
Chatbar.FocusLost:connect(function(Enter) -- Does the Enter argument identify himself as the Key:byte() that's equal to Enter?
if Enter then
if Chatbar.Text == '' then
return
end
ChatEvent:FireServer("chat", Chatbar.Text)
Chatbar.Text = ''
end
end)
ChatEvent.OnClientEvent:connect(function(Request, Message, Speaker) -- What are this arguments for?
Request = Request:lower()
if Request == "chat" then
CreateMessage(Message, Speaker)
end
end)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
My questions about this are:
What does OnServerEvent function do?
Is it a communication between the Server and the Client?
What does OnClientEvent function do ?
Is it a communication between the Client and the Server?
I'll include commentary questions inside the script.

7 comments
I want to make this clear. We are not a substitute for your brain. Everything we learned, you can learn the same way.
I know, I've checked the Wiki links of each thing, But I just want a quick resume. For me to clarify what is it. I'm not asking for a 30 pages explanation because that's located in the Wiki. I just want a small answer on each question so I understand it better.
And I know I can learn the same way, but that doesn't mean that I can't receive a bit of a push on understanding stuff that is not very clear for me in the Wiki.
OnServerEvent is the event fired when a client is using the FireEvent function on a RemoteEvent. The server takes action with the event taking place and runs the function you define in the connection line. Basically the same way around for the OnClientEvent just for server to client communication.
Thanks M39a9am3R, that's better than the wiki.
These type of understanding type questions are fine, ignore elunate
I'll do. I just want a better understanding of it. I'm not telling you to explain me all the script, just bits that I don't understand.