How to use "[" in a string

so recently i tried to remove an unwanted [ from a string using gsub however it gives me a syntaxerror saying "invalid match pattern:expected ] at the end of the string to close a set

does anyone know how to solve this? and if not, know a workaround to achieve this

also this is my first ever post so im sorry if i did something wrong

1 Like

Send the script to me, please.

sure however im new to making posts so how to send the code in like a picture?

game.ReplicatedStorage.Events.ChatbotMessaged.OnServerEvent:Connect(function(plr,msg)
msg = string.gsub(msg,plr.Name,“”)
msg = string.gsub(msg,“ChatBot →”,“”)
msg = string.gsub(msg,“[”,“”)
chat:Chat(workspace.Bob.Head,msg)
end)

1 Like

You should’ve send the script, but here it is

Use % for special characters. Example

name = "[John Doe"
name = name:gsub("%[", "")

Hope it helps! :smiley:

1 Like

thanks it worked and im sorry for replying late, like i said this is my first post but thank you for helping!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.