Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

When I try to put ( in a string it says it wants to be completed with a )?

Asked by 2 years ago

In my code I have a “(” but it’s expecting it to be finished with another ) so “()” but I only want the one (. How do I do that? Same thing with square brackets, and other Magic Characters. I'm replacing the ( with the () in a gsub

script.Parent.TextLabel.Text = string.gsub(script.Parent.TextLabel.Text, "(", "()")

1 answer

Log in to vote
1
Answered by
imKirda 4491 Moderation Voter Community Moderator
2 years ago

( is a magic character used for string capturing, if you want to use it as normal character you need to prefix it with %:

script.Parent.TextLabel.Text = string.gsub(script.Parent.TextLabel.Text, "%(", "()")
0
Yeah I know it was a magic character just didn't know how to use it in a string. Thanks. co_existance 141 — 2y
0
i said that it's magic character *used for string capturing* just so if you ever want to learn about it you know what to search for :wink: imKirda 4491 — 2y
Ad

Answer this question