I am making a plugin in an admin system which allows people to add flights to the status display in my new airport game. I needed to filter what goes in as the destination. What my issue is is that I want to block text that has been filtered if a '#' is detected. I have tried string.find() and string.match() but both have errored back with the following error: Line:40 - bad argument #1 to '?' (string expected, got Object)

You need to click more below to see the whole code, the beginning of it is instructions for EISS plugin making. Ignore it :| Here is the code below:

	--[[
	SERVER PLUGINS' NAMES MUST START WITH "Server: "
	CLIENT PLUGINS' NAMES MUST START WITH "Client: "
	
	Plugins have full access to the server/client tables and most variables.
	
	You can use the MakePluginEvent to use the script instead of setting up an event.
	PlayerChatted will get chats from the custom chat and nil players. 
	PlayerJoined will fire after the player finishes initial loading
	CharacterAdded will also fire after the player is loaded, it does not use the CharacterAdded event.
	
	server.MakePluginEvent('PlayerChatted',function(msg,plr) 
		print(msg..' from '..plr.Name..' Example Plugin')
	end)
	
	server.MakePluginEvent('PlayerJoined',function(p) 
		print(p.Name..' Joined! Example Plugin') 
	end)
	
	server.MakePluginEvent('CharacterAdded',function(plr) 
		server.RunCommand('name',plr.Name,'BobTest Example Plugin') 
	end)
	
--]]

return function(set)
	set.MakeCommand('Add a flight to the board',2,set.Prefix,{'gate','flightstatus','fs'},{'flight#','gate','status','destination'},function(plr,args)

local TextS = game:GetService("Chat")	
	------workspace.Folder.FI:Fire(args[1],args[4],args[3],args[2])
	local GT = workspace.Flights:FindFirstChild(args[2])
	
	if GT.Dest.Value == "" then
		local success, errorMessage = pcall(function()
  FILTERED = TextS:FilterStringForBroadcast(args[4], plr.UserId)
end)
		
	if not success then error("FAILED TO FILTER DESTINATION TEXT. PLEASE TRY AGAIN LATER. Error Code: "..errorMessage) end	
		
		if string.find(FILTERED, '#') then error("DESTINATION ENTERED CONTAINS FILTERED TEXT. PLEASE USE THE /us or /ugate COMMAND TO ENTER A DIFFERENT DESTINATION") else
		GT.Dest.Value = FILTERED 
		end
		end
	if GT.Status.Value == "" then GT.Status.Value = args[3] end
	if GT.Gate.Value == "" then GT.Gate.Value = args[2] end
	if GT.Flight.Value == "0" then GT.Flight.Value = args[1] end
	
	
	
	end)
	--Plugin function to run. Has access to script globals and the server/client tables.
	end
	

6 comments

0

Just check if FILTERED == args[4], if it doesn't it means it has been filtered.

0

Check it, and negative. Its | GT.Dest.Value = FILTERED |

0

The error is located at line 40, please provide that piece as it's crucial

0

I put in the full script to make it easier

0

First you should use, String:match(m,r) for this. Tell me what you get running print(type(FILTERED)) around line 39 too

0

It came out as "string"