-
What do you want to achieve? I want to have a strikethrough go through words or phrases that would be filtered if the message was sent through chat. (In a custom chat frame)
-
What is the issue? I’m trying to use RichText to tell the user that they can’t use certain phrases, but the RichText settings I entered are visible to the player. (I also don’t want players trying to put RichText in the chat)
Aspect ratio is a tiny bit stretched bc I couldn’t figure out how to change OBS resolution and actually have an effect on my weird monitor
- What solutions have you tried so far? I’ve searched for help, and haven’t found an easy way to strikethrough text without these results.
LocalScript
--Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--Communication
local communication = ReplicatedStorage:WaitForChild("Communication")
local filterTextFunction = communication:WaitForChild("FilterText")
local shouldFilterCheck = true
chatTextBox:GetPropertyChangedSignal("Text"):Connect(function()
if shouldFilterCheck then
local message = chatTextBox.Text
local filteredChars = {}
local returnMessage = ""
if message == "" then
module.tween(chatTextEntry,TweenInfo.new(.1,Enum.EasingStyle.Back),{Size = UDim2.new(1,0,.15,0)})
else
local filteredText = filterTextFunction:InvokeServer(message,Enum.TextFilterContext.PublicChat)
print(filteredText)
for index, character in pairs(string.split(filteredText,"")) do
if character ~= string.sub(message,index,index) then
print("Adding character to table" .. string.sub(message,index,index))
table.insert(filteredChars,index)
end
end
for tableIndex, characterIndex in pairs(filteredChars) do
if filteredChars[tableIndex-1] ~= characterIndex-1 then
returnMessage = returnMessage .. "<font color = 'rgb(255,0,0)'> <s>" .. string.sub(message,characterIndex,characterIndex)
else
if tableIndex == #filteredChars then
returnMessage = returnMessage .. "</s></font>" .."<font color = 'rgb(255,0,0)'><s>" .. string.sub(message,characterIndex,characterIndex) .. "</s></font>"
else
returnMessage = returnMessage .. "</s></font>" .."<font color = 'rgb(255,0,0)'><s>" .. string.sub(message,characterIndex,characterIndex)
end
end
end
end
print(returnMessage)
if #filteredChars >=1 then
shouldFilterCheck = false
chatTextBox.Text = returnMessage
shouldFilterCheck = true
end
end
end)
Server Script
--Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--Communcation
local communication = ReplicatedStorage:WaitForChild("Communication")
local filterTextFunction = communication:WaitForChild("FilterText")
filterTextFunction.OnServerInvoke = function(player,textToFilter,chatContext)
local filteredText = module.FilterText(textToFilter,player.UserId,chatContext)
return filteredText:GetChatForUserAsync(player.UserId)
end
ModuleScript (Only one function is relevant and is only used by server)
local module = {}
module.FilterText = function(stringToFilter, userId, context)
local filteredText = TextService:FilterStringAsync(stringToFilter,userId,context)
return filteredText
end
return module
Is there some other way I can use strikethrough that would be easier?
Thanks in advance,
Lord of Cheese