local mps = game:GetService("MarketplaceService")
local ts = game:GetService("TextService")
local rem = rep:WaitForChild("UpdateTag")
rem.OnServerEvent:Connect(function(player, tagText, tagFont, tagColorR, tagColorG, tagColorB, tagStroke, tagBrackets)
print(tagText)
local tag = game.Workspace:WaitForChild(player.Name).Head.Nametag.Frame.VIP
local owns = mps:UserOwnsGamePassAsync(player.userId, 6659891)
if owns then
local filteredTextResult = ts:FilterStringAsync(tagText, player, 1)
if tagBrackets == 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)
:FilterStringAsync() expects three parameters, the first is the string to be filtered, second is the UserId of the player and third is an optional context enum. You are passing the player instance as the second parameter instead of the UserId, explaining the “Unable to cast Instance to int64” error. Exchange player with player.UserId.
The above method also returns an instance, not a string, which explains the concatenation error (tag.Text = "["..filteredTextResult.."]"). Use one of the following functions on the instance to get filtered text: GetChatForUserAsync, GetNonChatStringForBroadcastAsync, GetNonChatStringForUserAsync. They each filter text to a different extent, so make sure to read up on them.
Example:
local ts = game:GetService("TextService")
local text = "hello"
local filteredtext = ts:FilterStringAsync(text, game.Players.byc14.UserId):GetNonChatStringForBroadcastAsync()
print(filteredtext)