Filtering Message Not Working?

Basically, my script to filter a message is not working. Instead of printing out the filtered text, it just prints “Instance”. Here is all of my code.

Script inside TextBox:

local http = game:GetService("HttpService")
local cooldown = false
local rem1 = game.ReplicatedStorage:WaitForChild("Server")
local rem2 = game.ReplicatedStorage:WaitForChild("Client")

script.Parent.Parent.Parent.Send.SendGui.TextButton.MouseButton1Click:Connect(function()
	rem1:FireAllClients()
	print("client fired")
	rem2.OnServerEvent:Connect(function(player, message)
		print(message)
		local Data = {
			["content"] = message
		}
		Data = http:JSONEncode(Data)
		print(Data)
		http:PostAsync("https://webhook.lewisakura.moe/api/webhooks/yummyyummydonttakemytokenlol", Data)
		cooldown = true
		wait(60)
		cooldown = false
	end)
end)

LocalScript in startergui:

local rem = game.ReplicatedStorage:WaitForChild("Server")
local rem2 = game.ReplicatedStorage:WaitForChild("Client")
local TextService = game:GetService("TextService")
local textbox = game.Workspace:WaitForChild("Part").SurfaceGui.TextBox
local player = game.Players.LocalPlayer
local userid = player.UserId
local filter1 = game.ReplicatedStorage:WaitForChild("FilterServer")
local filter2 = game.ReplicatedStorage:WaitForChild("FilterClient")
local earlymessage = ""
local message = ""

textbox.FocusLost:Connect(function(inputObj)
	earlymessage = textbox.Text
	print(earlymessage)
	filter1:FireServer(userid, earlymessage)
	filter2.OnClientEvent:Connect(function(msg)
		message = msg
	end)
end)

rem.OnClientEvent:Connect(function()
	rem2:FireServer(message)
	print("server fired")
end)

Server Script for filtering in sss:

local rem = game.ReplicatedStorage:WaitForChild("FilterServer")
local rem2 = game.ReplicatedStorage:WaitForChild("FilterClient")
local TextService = game:GetService("TextService")

rem.OnServerEvent:Connect(function(userid, startmessage)
	local success, errorMessage = pcall(function()
		local finalmessage = TextService:FilterStringAsync(userid, startmessage):GetNonChatStringForBroadcastAsync()
		rem2:FireAllClients(finalmessage)
		print(finalmessage)
	end)
	if not success then
		warn("Error filtering text:", errorMessage)
	end
end)

The error is in the last script, it just prints instance and does not send anything to the discord.

did you try using tostring() inside of the print?

Ill try that now. Ill update you as well.

Now it sends to the discord, but only sends “Instance”.

Ok I see your issue. you have the arguments for FilterStringAsync() backwards. It goes: FilterStringAsync(string,userid) and you put FilterStringAsync(userid,string).


Heres a screenshot of the format of the function.

Okay, I tried that but now I get this error:
Error filtering text: Unable to cast Instance to int64
Any fix for this?

Did you make sure you put the player’s UserID and not the player instance?

Not sure is this will work, but try putting the string in the async function inside a tostring()

Yes, 100%, Ill try the other thing now

If you mean doing tostring(startmessage), that didn’t work either, still same error.

add a print(tostring(userid)) to make sure the userid is actually a number, because the error you’re experiencing is caused by having an instance for the userid.

WE FIXED IT! I had to add player into the remote because it was getting it automatically and the script thinks that’s the userid, but its fixed now! Thanks so much!

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