Need help w filtering text

I am trying to filter text as the game lets players choose a name for there characters, and I keep running into an error with it, attempt to index string with ‘Value’

Event2.OnServerEvent:Connect(function(player,Value1,Value2)
	if rolled == true then
		return
	end
	
	local PlayerStats = Stats:FindFirstChild(player.Name)
	
	
	local text = Value2
	local filteredText = ""
	local success, errorMessage = pcall(function()
		Value2.Value = TextService:FilterStringAsync(text, player.UserId):GetNonChatStringForBroadcastAsync()
	end)
	if not success then
		warn("Error filtering text:", text, ":", errorMessage)
		print("try again lil bro")
		Event2:FireClient(player)
		return
	end

Maybe because of the local? The “text” local is only a instance, if you need the string, you may do local text = Value2.Value

1 Like

now its printing nil whenever i print text, perhaps the local script will help u too

lua

local Value1 = nil
local Value2 = nil
MaleButton.MouseButton1Click:Connect(function()
	Value1 = true
end)

FemaleButton.MouseButton1Up:Connect(function()
	Value1 = false
end)

PlayerNameBox.FocusLost:Connect(function()
	local text = PlayerNameBox.Text
	
	Value2 = text
end)


Frame.Confirm.MouseButton1Up:Connect(function()
	if Value1 == nil then
		return
	end
	
	if Value2 == nil then 
		return 
	end
	
	Event2:FireServer(Value1,Value2)
	
end)

Event2.OnClientEvent:Connect(function()
	Frame.PlayerName.PlaceholderText = "Censored, Please Try again."
end)

Oh hold on, you are sending Text, in the ServerScriptService you got “Value2.Value”, the right line is:

Value2 = TextService:FilterStringAsync(text, player.UserId):GetNonChatStringForBroadcastAsync()
1 Like

it worked, however whenever i type in something thats moderated the script still works, does it only work ing and out of studio?

Yeah, I think it does not work in Roblox Studio.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.