My script is meant to generate a random word for the whole server, and then filter it to confirm that it’s not a bad word. If it’s a bad word, the script will repeat the whole function until an accepted word is returned.
To optimise this process, I used a “dummy” player, to run basic checks on behalf of the server, guaranteeing that there’s nothing that shouldn’t be there.
If I were to check each player’s filter on a singular word, it could take an extremely long time depending on the server size.
The code is this;
local randPlr = game.Players:GetPlayers()[1]
local id = randPlr.UserId
local word = wordList.pickWord(id) -- returns a random word
local txt = ''
local success, err = pcall(function()
txt = TextService:FilterStringAsync(word, id, Enum.TextFilterContext.PublicChat)
end)
if success and game.Players:FindFirstChild(randPlr.Name) then
local fixed = txt:GetNonChatStringForUserAsync(id) -- here
return {true, fixed}
else
return {false, '#'}
end
With the error occurring on this line:
local fixed = txt:GetNonChatStringForUserAsync(id)
error: > The target user must be connected to the current server
I’m not sure how to replicate or fix this, as it has only happened a few times.
Any help would be greatly appreciated 