Advertisement
HowToRoblox

Main Script

Aug 11th, 2023
3,592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. local message = "im so lonely"
  2. local allowedChars = "abcdefghijklmnopqrstuvwxyz "
  3. allowedChars = allowedChars:split("")
  4.  
  5. local createNPCs = require(script:WaitForChild("CreateNPCs"))
  6.  
  7. function filterMessage(msg: string)
  8.    
  9.     msg = msg:lower()
  10.     local filteredMsg = ""
  11.  
  12.     for _, char in pairs(msg:split("")) do
  13.  
  14.         if table.find(allowedChars, char) then
  15.             filteredMsg = filteredMsg .. char
  16.         end
  17.     end
  18.    
  19.     return filteredMsg
  20. end
  21.  
  22. game.Players.PlayerAdded:Connect(function(plr)
  23.    
  24.     plr.Chatted:Connect(function(msg, _recipient)
  25.        
  26.         msg = filterMessage(msg)
  27.        
  28.         if msg == message then
  29.            
  30.             createNPCs(plr)
  31.         end
  32.     end)
  33. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement