You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to create a script that will replace a given string that is not allowed to another string through LocalScript
Example:
*Server does not allow the word “cheese”, the replacement word “banana” *
And I’m typing ‘imcheese’ and it will turn into 'imbanana’
*Typing
Replaced
-
What is the issue? Include screenshots / videos if possible!
It only works great when the string the player is entering is not uppercase, otherwise it will spam a lot of replacement strings and
it will not remove capital letters
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
yes, but those are posts that need help how to using roblox studio features
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
function AutoDetect(UI:TextBox)
UI.Changed:connect(function(P)
if tostring(P) == "Text" then
for i,Name in pairs(DontThisTexts) do
if string.match(string.lower(UI.Text),string.lower(Name)) then
if UI:IsA("TextBox") then
--The Main Is Here,What I Wrong With This Script???
local V = UI.Text:split(Name)
UI.Text = ''
if V[2] ~= nil then
UI.Text = V[1]..Replacer..V[2]
elseif V[1] ~= nil then
UI.Text = V[1]..Replacer
elseif V[1] == nil then
UI.Text = Replacer
end
end
end
end
end
end)
end
for _,UI in pairs(game.Players.LocalPlayer:WaitForChild("PlayerGui"):GetDescendants()) do
AutoDetect(UI)
end
game.Players.LocalPlayer:WaitForChild("PlayerGui").DescendantAdded:connect(function(UI)
AutoDetect(UI)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
[Edited Script] not best but it’s good (:
function AutoDetect(UI:TextBox)
UI.Changed:connect(function(P)
if tostring(P) == "Text" then
for i,Name in pairs(DontThisTexts) do
--(if string.match(string.lower(UI.Text),string.lower(Name)) then) I Removed This
if UI:IsA("TextBox") then
local function createPattern(word: string): string
local sets = {}
for letter in string.gmatch(word, ".") do
table.insert(sets, ("[%s%s]+"):format(string.lower(letter), string.upper(letter)))
end
return table.concat(sets, "")
end
local ThisNew,_ = string.gsub(UI.Text,createPattern(Name),Replacer)
UI.Text = ThisNew
end
--end
end
end
end)
end
for _,UI in pairs(game.Players.LocalPlayer:WaitForChild("PlayerGui"):GetDescendants()) do
AutoDetect(UI)
end
game.Players.LocalPlayer:WaitForChild("PlayerGui").DescendantAdded:connect(function(UI)
AutoDetect(UI)
end)