Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is Roblox text filtering turning out nil?

I am trying to filter a string that goes from a local script, to a script, to all clients. The remote event works fine, but now that I have to filter it, it makes the output string "Nil". I am completely lost and I have tried every combination I could think of.

Script:

game.ReplicatedStorage.RadioSend.OnServerEvent:Connect(function(player, test)
	testsend = tostring(test) --Test is the string I am trying to filter
	print(testsend)
	local FiSuccess, FiError = pcall(function()
		radioFilterResult = TextService:FilterStringAsync(testsend, player.UserId)
		return
	end) 
	local radioFilterDone = radioFilterResult
	if FiSuccess then
		print(radioFilterDone)
		game.ReplicatedStorage.RadioReceive:FireAllClients(radioFilterDone)
		return radioFilterResult
	end
	if FiError then
		warn("Filter Error")
	end
end)

1 answer

in the line

local FiSuccess, FiError = pcall(function()
	radioFilterResult = TextService:FilterStringAsync(testsend, player.UserId)
	return
end)

radio filter result is incased into a deeper zone meaning outside the pcall it cannot be acessed. to fix this simple change the pcall to this (not even changing the pcall just adding a line before it.)

local radioFilterResult;
local FiSuccess, FiError = pcall(function()
	radioFilterResult = TextService:FilterStringAsync(testsend, player.UserId)
	return
end)

this will make radioFilterResult acessable outside the pcall too and making it not nil as seen by the scripts interprater.

2 comments

0

I hope this helps out if you still get nil or an error send it here. k thx bye!

0

Still getting nil :/

This discussion is preserved as it was. New answers, comments, and votes are closed.