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)
print(FilteredSuccess)
script.Parent.Parent.FilteredText.Text = FilteredSuccess
else
-- The player stopped editing without pressing Enter
script.Parent.EditName.Text = ""
end
end
script.Parent.FocusLost:Connect(onFocusLost)
--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()
--end)
--if success then
-- return FilterSuccess
--else
-- warn("Couldn't filter text that was sent!")
--end
end
game.ReplicatedStorage.Events.Data.GetFilteredName.OnServerInvoke = ReturnTextFiltered
Here’s also the place file.
textthingy.rbxl (29.8 KB)