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

[SOLVED] String filtering doesn't work, all words passed the filter? [closed]

Asked by
Rheines 661 Moderation Voter
5 years ago
Edited 5 years ago

I'm trying to create a party system, and users are able to name their own party for other players to see. I would need to filter the name string if I don't want actions to be taken against me. I tried filtering the string, but it seems if I print the name of the party, it is not filtered. Is there anything wrong?

--Filter's the party name.
function module:filter(name, from)
    local filtered 
    local success, errormessage = pcall(function()
        filtered = TS:FilterStringAsync(name, from.UserId)
    end)
    if success then
        filtered = filtered:GetNonChatStringForBroadcastAsync()
        return filtered
    else
        warn(from.Name.."'s party name does not pass ROBLOX's filter.")
        WarningRemote:FireClient(from, "Warning", "PARTY NAME DEFAULTED")
        --Use default party name if filter failed.
        return "LET'S PLAY"
    end
end

--Create new party with specified requirements and size.
function module:new(creator, name, requirement, size)
    if not creator then return end
    --Set default values for party if arguments are not given.
    if name then
        name = string.upper(module:filter(name, creator))
    else
        name = "LET'S PLAY"
    end
    requirement = requirement or 1
    --Party size defaulted to 4 if not specified or a maximum of 6 people
    if size then
        size = math.min(math.max(1,size), 6)
    else
        size = 4
    end

    module.inParty[creator.Name] = true

    local group = {}
    group.identifier = helper:getidentifier()
    group.leader = creator.Name
    group.name = name
    group.requirement = requirement
    group.banned = {}
    group.members = {[creator.Name] = true}

    return group
end

This is how I check the party's name and number of parties. All parties are put in a dictionary with a unique identifier.

while wait(2) do
    local length = {}
    for _, party in pairs(parties) do
        if party ~= nil then
            print(party.name)
            table.insert(length, party)
        end
    end
    print(#length.." parties created.")
end
0
Are you testing this in-game or in studio? I think filtering doesn't work if you're testing in studio. User#20279 0 — 5y
1
Both. Rheines 661 — 5y
0
What words are you putting in that you expect to be filtered? Also, try putting numbers in as the broadcast function usually tags those. User#20279 0 — 5y
0
Numbers and the usual swear words. Rheines 661 — 5y
View all comments (3 more)
0
It seems to work now but I did not know what happened before. Rheines 661 — 5y
0
I did read something about FilterStringASync possibly breaking if results are "cached and reused". Not sure if it relates to your problem though : https://developer.roblox.com/api-reference/function/TextService/FilterStringAsync User#20279 0 — 5y
0
if your trying it in studio, it has no filter. the8bitdude11 358 — 5y

Locked by JesseSong

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?