I'm having a problem with RemoteEvent. It's sending my print message three times when it should really be sending it once. Can you take a look?
This is the hierarchy of what happens: Localscript->Modulescript activates RemoteEvent->OnServerEvent hears that activation and SHOULD fire only one print message yet fires three!?
Localscript (sniped to the part where it sends a fire to the modulescript) :
Input.FocusLost:connect(function(enterWasPressed) --//If enter key was pressed, thus submitting a chatmsg.
if enterWasPressed then
print("Executing enterWasPressed...");
if InputFrame.Visible == true then
chathandler.add(Input.Text); --//Modulescript usage kicks in here.
Input.Text = ("");
InputFrame.Size = UDim2.new(0.22,0,0.038,0);
InputFrame.Visible = false;
end
end
end)
--[===[Deprecated:
--]===]
Modulescript:
local chathandler = {}
--//Events:
local chatAdd = game.Workspace["Remote(s)"].chatAdd;
--//
function chathandler.add(msg)
print("Executing chathandler.add...");
chatAdd:FireServer(msg);
end
return chathandler;
Serverscript w/the OnServerEvent listener:
chatAdd.OnServerEvent:connect(function(player,msg)
print("Executing server event...");
print(msg);
end)
Output:
http://i.imgur.com/AJ0EYgj.png
What the hell is happening? All I have is a simple input bar that mimics the ROBLOX chatbar. I know that they recently released their own chat API but I want to try to make mine so it's unique and it's mine. Help???
It's worth noting that even if I fire to the OnServerEvent listener (RemoteEvent) directly within the local script, the same result happens.
Update(s):
*I did a quick fix and removed the Input:ReleaseFocus() line and this is now the output:
Executing enterWasPressed...
Executing chathandler.add...
Hi, testing!
nil
Executing server event...
Hi, testing!
It didn't change much! Somebody help please. Here's the full localscript:
--> Initial frame size on y's: 0.038 - > to: 0.06
local StarterGui = game:GetService("StarterGui");
local InputGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("Chat");
local InputFrame = InputGui.InputFrame;
local Input = InputFrame.Input;
local modules = game.Workspace["Module(s)"];
local chathandler = require(modules.ChatHandler);
local charLimit = 78;
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
Input.FocusLost:connect(function(enterWasPressed) --//If enter key was pressed, thus submitting a chatmsg.
if enterWasPressed then
print("Executing enterWasPressed...");
if InputFrame.Visible == true then
chathandler.add(Input.Text); --//Modulescript usage kicks in here.
Input.Text = ("");
InputFrame.Size = UDim2.new(0.22,0,0.038,0);
InputFrame.Visible = false;
end
end
end)
Input.Changed:connect(function(whatChanged) --//Input monitor, monitors keystrokes while user is inputting text.
if whatChanged == ("Text") then
if string.len(Input.Text) >= charLimit then
Input.Text = Input.Text:sub(1,charLimit);
if InputFrame.ErrorC.Visible == false then
InputFrame.ErrorC.Visible = true;
end
else
if InputFrame.ErrorC.Visible == true then
InputFrame.ErrorC.Visible = false;
end
end
if Input.TextFits == false then
if InputFrame.Size == UDim2.new(0.22,0,0.038,0) then
InputFrame.Size = UDim2.new(0.22,0,0.06,0);
end
end
end
end)
function onKeyPress(actionName, userInputState, inputObject) --//When you press the "/" key, mimicking ROBLOX chat.
if userInputState == Enum.UserInputState.Begin and actionName == "keyPress/" then
if InputFrame.Visible == false then
InputFrame.Visible = true;
Input:CaptureFocus();
end
end
end
game.ContextActionService:BindAction("keyPress/", onKeyPress, false, "/"); --//Binds.
--[===[Deprecated:
--]===]
Help!
Note: This is just a user input bar that mimics ROBLOX's chat input bar so when the user presses "/" they enter text and when focus is lost it fires to modulescript...

4 comments
Input:ReleaseFocus(). What's the point of this line? Focus is released automatically when enter is pressed.
I did a quick fix, can you check now? Still pretty much same results!
That output looks right to me. Are you testing with play solo? Have you tried this with Start Server and looked at the output on the server versus the output on the client?
I tested with SOLO and SERVER. I got that type of output. Why am I not getting one print but two prints and a nil print!? Why? How come? How can I get just one print? This makes no sense. Do help me.