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