Hello, I’m Floosed… A Roblox game developer. I am creating a system where the players can Create a Business on a UI, and when they press the “Create” button it appears on a Text Label inside of a Surface Gui, I’m confused on how to program this idea. If anyone could show some possible ways to do this, it would be appreciated! Example below
Rough example:
local function filterText(text)
local filteredText = ""
-- Filter the string here. This is a must, required by Roblox ToS.
return filteredText
end
CreateButton.MouseButton1Down:Connect(function()
SurfaceGui.TextLabel.Text = filterText(TextInput.Text)
end)
To make sure, Inside the filteredText string, I would put moderated words, yes?
That’s because you didnt return a filtered text, it was blank.
Roblox has a built-in service for this you can see here:
https://developer.roblox.com/en-us/api-reference/function/Chat/FilterStringForBroadcast
It has an example near the bottom of the page.
Well I was going to let you figure this out since its pretty simple, so you can learn on your own, but I’ll be nice and help you with the final result:
local Player = game:GetService("Players").LocalPlayer
local CreateButton = script.Parent
local SurfaceGui = workspace.ModelLabel.Part.SurfaceGui
local TextInput = script.Parent.Parent.TextBox
local function filterText(text)
local filteredText = ""
local success, message = pcall(function()
filteredText = game:GetService("Chat"):FilterStringForBroadcast(text, Player)
end)
return filteredText
end
CreateButton.MouseButton1Down:Connect(function()
SurfaceGui.TextLabel.Text = filterText(TextInput.Text)
end)
This is only local so he would need to use a remote if he wants other people to see the business name
Oops! You are right. I am not sure how I missed that. Hopefully he knows how a Remote Event works to send the text to the server and have the server filter it and then display it for everyone to see.
I know how Remote Events work, dw