Error filtering text: whatever text is being filtered goes here : Unable to cast Instance to int64 - Server - ChangeBio:11
The “Text” value that comes from the local script is the text from a textbox where a player can enter their new in-game bio
local Players = game:GetService("Players")
local Event = game.ReplicatedStorage.Profile.ChangeBio
local TextService = game:GetService("TextService")
Event.OnServerEvent:Connect(function(player,Text)
local filteredText = ""
local success, errorMessage = pcall(function()
filteredText = TextService:FilterStringAsync(Text,player)
end)
if not success then
warn("Error filtering text:", Text, ":", errorMessage)
-- Put code here to handle filter failure, I got this off the dev page and i'm not sure what code to put here, i have been trying to get text filtering to work for a while now and just can't figure it out even with all the stuff i read
end
player.Bio.Value = filteredText -- I have a string value in the player to store their bio
print(filteredText)
end)
Looking at: TextService | Roblox Creator Documentation
I can see that it expects the UserId (int64) and not the player instance. Try sending it player.UserId as a parameter instead
That’s because the second value the pcall() function returns is an error instance. Check out Programming in Lua : 8.4 for more details. Try using errorMessage.code instead. (might have to call tostring() on the code, idk if it returns a string or if a string is demanded)
Looking at TextService | Roblox Creator Documentation if you scroll down to “Parameters” you can see the second parameter is called “fromUserId” and next to it you can see the datatype it uses (int64). Next to that you also have a brief explanation on what it is and what it’s used for.
Roblox has made this function and needs the parameters for it to work correctly.
Because, text/numbers are filtered depending on the users’ account settings/age. The UserId is a unique number sequence associated with only that account.
It’s just the parameters of the function. It follows as:
FilterStringAsync(string stringToFilter, int64 fromUserId, Enum.TextFilterContext textContext)