RemoteFunction returns string as "Instance"

Hello! I’ve been learning a bit about RemoteFunctions and Text Filtering via. TextService, and I’ve been trying to make a little system for fun where you can enter in text, and then have it filtered and displayed on the “OutputText” TextLabel beside the Textbox.


After finding out that using the filter functions requires them to be used on the server, I decided that a RemoteFunction would probably be handy for filtering the sent text, and then returning it back to the client. The main problem I’ve stumbled upon is that whenever I invoke the RemoteFunction with the player and text, all it returns is an “Instance” according to the output. Is there a reason for this?


Here’s the code below by the way:

-- Localscript inside the TextBox

local Player = game.Players.LocalPlayer

local function onFocusLost(enterPressed, inputObject)
	if enterPressed then

		local TextEntered = script.Parent.Text

		local FilteredSuccess = game.ReplicatedStorage.Events.Data.GetFilteredName:InvokeServer(Player, script.Parent.Text)


		script.Parent.Parent.FilteredText.Text = FilteredSuccess

		-- The player stopped editing without pressing Enter
		script.Parent.EditName.Text = ""


--ServerScript, where RemoteFunction code is handled

function ReturnTextFiltered(player, text)
	local FilteredNameAttempt = TextService:FilterStringAsync(text, player.UserId, 1)

	local FilterSuccess = FilteredNameAttempt:GetNonChatStringForBroadcastAsync()

	return FilterSuccess
	--local FilteredNameAttempt = TextService:FilterStringAsync(text, player.UserId, 1)

	--local FilterSuccess
	--local success, fail = pcall(function()
	--	FilterSuccess = FilteredNameAttempt:GetNonChatStringForBroadcastAsync()
	--if success then
	--	return FilterSuccess
	--	warn("Couldn't filter text that was sent!")

game.ReplicatedStorage.Events.Data.GetFilteredName.OnServerInvoke = ReturnTextFiltered

Here’s also the place file.
textthingy.rbxl (29.8 KB)

I would look into the page below, that behavior is correct.

Try: tostring(result)

Still didn’t work unfortunately, unless this line isn’t how you do it?

script.Parent.Parent.FilteredText.Text = tostring(FilteredSuccess)

Here’s the place file if you’re interested
textthingy.rbxl (29.8 KB)

Update: Unfortunately I didn’t realize that I didn’t need to send a player object at all since it’s auto-referenced when Invoking. Thanks to everyone who helped anyway!