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

How to filter text in scripts automatically? [Script Builder]

Asked by 6 years ago

Basically the title says it all:

-->> My script
print("this is my string! 'this is a smaller string!' my string is back again!")

I want that 'this is a smaller string...' part to be returned in a function e.g.

function getString(text)
return -->> 'this is a smaller string...'
end

Edit: Allow me to explain more, this is for a Script Building game, and I need this to filter any strings in the players' code so they can't swear. I've tried filtering the whole thing, but then it just turns into hashtags. Code:

filterAllTextInstances = function(str)
    for match in string.gmatch(str , '[^\.]+"') do
        print("found: " .. match)
        --str:gsub(match,game:service("ReplicatedStorage").FilterText:InvokeServer(match))
        print("filtered: " .. game.Chat:FilterStringForBroadcast(match,game.Players.LocalPlayer))
        str:gsub(match,game.Chat:FilterStringForBroadcast(match,game.Players.LocalPlayer))
    end
    return str
end

And it does not work. Thank you for your help.

Answer this question