local UIS = game:GetService("UserInputService")
local chatbar = script.Parent
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.Slash then
chatbar:CaptureFocus()
end
end)
chatbar.FocusLost:connect(function(EnterPressed)
if EnterPressed and chatbar.Text ~= "" and chatbar.Text ~= " " then
local message = chatbar.Text
local plr = chatbar.Parent.Parent.Parent
local chatstorage = game.Workspace:WaitForChild("ChatStorage")
local plrmessage = Instance.new("StringValue", chatstorage)
local sucess, message = pcall(function()
local filteredtext = message:FilterStringAsync(message)
plrmessage.Value = plr.Name..": "..filteredtext
wait(0.1)
chatbar.Text = "Press \"/\" to chat!"
end)
end
end)
I tried the roblox scripting wiki but I still don't get how to filter strings.. I also don't get what pcall(function() means and why in the example (http://wiki.roblox.com/index.php?title=Text_Filtering) in the wiki (labeled as server script) has this:
filteredMessage = Chat:FilterStringAsync(message, sender, recipient)
(I'm talking about what's inside of the parentheses). I know what it means when there is one word inside of the parentheses, but why are there three of them in the example, and how does it work? Sorry, I never learned these concepts... Could someone help?
