I want to achieve when you press enter inside a textbox a RemoteFunction will trigger and put the string inside the textbox through filtering and send it back to the localscript.
I don’t get any errors but it also doesn’t do anything.
This is my first time working with a RemoteFunction
Localscript:
local TextBox = script.Parent
local localplayer = game:GetService("Players").LocalPlayer
local FilterFunction = game.ReplicatedStorage.Functions:WaitForChild("FilterFunction")
local function SendMessage(message)
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
Text = message,
Color = Color3.fromRGB(150, 177, 255)
})
end
TextBox.FocusLost:connect(function(enterPressed)
if enterPressed then
local Result = FilterFunction:InvokeServer(script.Parent.Text,"System123")
return SendMessage(Result)
end
end)
Modulescript:
local FilterString = {}
function FilterString:Filter(String,Player)
local TXTS = game:GetService("TextService")
local success,ErrorMessage = pcall(function()
TXTS:FilterStringAsync(String,Player.UserId)
end)
if success then
return FilterString
else
return warn("Something went wrong while filtering: "..String.." Error: "..ErrorMessage)
end
end
return FilterString
Script:
local FilterFunction = game.ReplicatedStorage.Functions:WaitForChild("FilterFunction")
local FilterString = require(game.ServerStorage.ServerOnlyModules.FilterString)
FilterFunction.OnServerInvoke = function(Player,message,forwhat)
if forwhat == "System123" then
local FilterdMessage = FilterString:Filter(message,Player)
return FilterdMessage
end
end