Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

ChatGui through Filtering Enabled Help?

I am having issues with my chat GUI, for some reason it keeps spitting out the same exact error for no absolute visible reason to me, and it will have a funky twist to it as well when I do think I've fixed it. I have FilteringEnabled Enabled because, I want to make my MainFrame compliant with that. I am new to filtering enabled, and am trying to understand how to work with it.

The error is;

ServerScriptService.MainFrameCentral:77:attempt to concatenate local 'plr' (a userdata value)

The Local Script;

--There is previous code
	if key:byte() == 13 then
		game.Workspace.ChatDevice:InvokeServer(game.Players.LocalPlayer.Name, script.Parent.TextBox.Text)
		script.Parent.TextBox.Text = [[Press "/" or click here to chat.]]
	end
--There is later code

The Server Script;

function game.Workspace.ChatDevice.OnServerInvoke(plr, chat)
	local chatholder = game.ServerStorage.MainFrameData.Chat
	chatholder.Chat11.Value = chatholder.Chat10.Value
	chatholder.Chat10.Value = chatholder.Chat9.Value
	chatholder.Chat9.Value = chatholder.Chat8.Value
	chatholder.Chat8.Value = chatholder.Chat7.Value
	chatholder.Chat7.Value = chatholder.Chat6.Value
	chatholder.Chat6.Value = chatholder.Chat5.Value
	chatholder.Chat5.Value = chatholder.Chat4.Value
	chatholder.Chat4.Value = chatholder.Chat3.Value
	chatholder.Chat3.Value = chatholder.Chat2.Value
	chatholder.Chat2.Value = chatholder.Chat1.Value
	chatholder.Chat1.Value = plr .. ": " ..chat --This is line 77
	for _,v in pairs(game:service("Players"):children()) do
		game.Workspace.ChatRefresh:InvokeClient(v, chatholder.Chat1.Value, chatholder.Chat2.Value, chatholder.Chat3.Value, chatholder.Chat4.Value, chatholder.Chat5.Value, chatholder.Chat6.Value, chatholder.Chat7.Value, chatholder.Chat8.Value, chatholder.Chat9.Value, chatholder.Chat10.Value, chatholder.Chat11.Value)
	end
end

I don't understand, and in the Server-side Script, even if I did change "plr" to "plr.Name" the chat will work but will show M39a9am3R: M39a9am3R. I have no idea why, if anyone could explain this to me, any help would be appreciated. Thank you.

1 answer

✓ Accepted answer

Refer to the documentation of OnServerInvoke.

It implicitly passes a reference to the LocalPlayer as the first argument.

Thus your invocation in your LocalScript causes the OnServerInvoke listener to receive

  • LocalPlayer (plr)
  • LocalPlayer.Name (chat)
  • TextBox.Text (you only have 2 arguments so this is thrown out)

Since you are only taking two parameters, you're getting LocalPlayer and LocalPlayer.Name.


Solutions:

Either

  • modify your OnServerInvoke listen to have a dummy variable for the LocalPlayer you aren't caring about

  • don't send LocalPlayer.Name since LocalPlayer is already being passed (the cleaner option)

1 comment

0

Oh, I didn't know the OnServerInvoke thing automatically ran the Local Player, I get it now. Thank you, I am sure this is the right answer, but I won't get to testing it until later today.

This discussion is preserved as it was. New answers, comments, and votes are closed.