So below there is an GUI which was made to fire an event to the server to change the players custom tag above there head but I ran into this issue where the string wont remove the brackets and filter?
Error: ServerScriptService.UpdateTag:13: malformed pattern (missing ‘]’)
Code:
local mps = game:GetService("MarketplaceService")
local ts = game:GetService("TextService")
local rem = rep:WaitForChild("UpdateTag")
local filteredTextResult = ""
rem.OnServerEvent:Connect(function(player, tagText, tagFont, tagColorR, tagColorG, tagColorB, tagStroke)
local owns = mps:UserOwnsGamePassAsync(player.userId, 6659891)
if owns then
local tag = game.Workspace:WaitForChild(player.Name).Head.Nametag.Frame.VIP
local brackets = string.find(tagText, "]", 1)
local unb = string.gsub(tagText, "]", "")
local unb2 = string.gsub(unb, "[", "")
if brackets == true then
filteredTextResult = ts:FilterStringAsync(unb2, player.userId)
else
filteredTextResult = ts:FilterStringAsync(tagText, player.userId)
end
if brackets == true then
tag.Text = "["..filteredTextResult.."]"
else
tag.Text = filteredTextResult
end
tag.TextColor3 = Color3.fromRGB(tagColorR, tagColorG, tagColorB)
tag.Font = tagFont
tag.TextStrokeTransparency = tagStroke
end
end)