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

Grabbing text from a text filter will not work, any possible fix?

Asked by 4 years ago
Edited 4 years ago

Ok so I'm making a Custom Chat tag script. But when filtering the text it comes up with an error. My script is this:

local TextBox = script.Parent.Parent.TextBox
local TextService = game:GetService("TextService")

local Plr = script.Parent.Parent.Parent.Parent.Parent.Parent

local function Filter(Text)
    local Obj 

    local Suc, Err = pcall(function()
        Obj = TextService:FilterStringAsync(Text, Plr.UserId)
    end)

    if Suc then
        return Obj
    else
        warn(Err)
    end
end

local function TextGrab(TextObj)
    local Text = ""

    local Suc, Err = pcall(function()
        Text = TextObj:GetNonChatStringForUserAsync(Plr.UserId)
    end)

    if Suc then
        return Text
    else
        warn(Err)
    end
end

script.Parent.MouseButton1Click:Connect(function()
    local Obj = Filter(TextBox.Text)

    local Text = TextGrab(Obj)

    TextBox.Text = Text
end)

script.Parent.TouchTap:Connect(function()
    local Obj = Filter(TextBox.Text)

    local Text = TextGrab(Obj)

    TextBox.Text = Text
end)

and the error is this:

ChatTagEditor.Dark.Lighter.TextButton.Script:39: invalid argument #3 (string expected, got nil) 'ChatTagEditor.Dark.Lighter.TextButton.Script', Line 39

If anyone could help it would be apprciated.

Answer this question