I'm making a custom chat system that uses RemoteFunctions to give a chat handler script the required values to send a chatted message, through a custom GUI, and a RemoteEvent to send the message to all players in the game. I started building it yesterday, and overall it looks good. But I get an error while connecting an event listener to the remote function saying OnServerInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available.
I'll provide full code snippets of everything used for this. A good and reasonable answer would be perfect and well appreciated. Thanks.
P.S. I know that my chat script isn't fully complete. I'm just showing you how I'm trying to send arguements to a RemoteFunction.
Local chat script (ScreenGui):
local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local chatEvent = game.Workspace.SendMessage
local sendChatInfo = game.Workspace.ChatInvoker
local chatting = false
local chatserv = game:GetService("Chat")
uis.InputBegan:Connect(function(input)
if input.InputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.Slash then
if not chatting then
chatting = true
script.Parent:CaptureFocus()
end
else if input.KeyCode == Enum.KeyCode.Return then
if chatting then
chatting = false
local msg = script.Parent.Text
sendChatInfo:InvokeServer(plr, msg)
script.Parent:ReleaseFocus()
end
end
end
end
end)
Custom Chat Handler (global script):
local SendMessageEvent = game.Workspace.SendMessage
local ChatInvoker = game.Workspace.ChatInvoker
ChatInvoker.OnServerInvoke:Connect(function(plr, msg)
game.Chat:FilterStringAsync(msg)
SendMessageEvent:FireAllClients(plr, msg)
end)
Remember; the error is coming from the chat handler that tries to add an event listener to a RemoteFunction at line 3 of the chat handler. There's nothing else conflicting.
Any assistance to help me build an accurate custom chat system is also acceptable.
