Advertisement
HowToRoblox

ChatServer

Oct 18th, 2020
1,303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. local msgContainer = game.ReplicatedStorage:WaitForChild("Containers"):WaitForChild("ChatMessageContainer")
  2.  
  3. local onChatInputted = game.ReplicatedStorage:WaitForChild("RemoteEvents"):WaitForChild("ChatEvent")
  4.  
  5.  
  6. onChatInputted.OnServerEvent:Connect(function(plr, msg)
  7.  
  8.  
  9.     local filteredText
  10.  
  11.     local filteredString
  12.  
  13.  
  14.     local stringValue = game.ReplicatedStorage:WaitForChild("Templates"):WaitForChild("ChatMessageTemplate"):Clone()
  15.  
  16.  
  17.     local success, errormsg = pcall(function()
  18.  
  19.  
  20.         filteredText =  game:GetService("TextService"):FilterStringAsync(msg, plr.UserId)          
  21.     end)
  22.  
  23.  
  24.     if success then
  25.  
  26.         local success2, errormsg2 = pcall(function()
  27.  
  28.  
  29.             filteredString = filteredText:GetNonChatStringForBroadcastAsync()
  30.  
  31.         end)
  32.  
  33.  
  34.         if success2 then
  35.  
  36.             stringValue.Text = "[" .. plr.Name .. "] " .. filteredString
  37.  
  38.  
  39.             stringValue.Parent = msgContainer
  40.            
  41.             for i = 50, 0, -1 do
  42.                
  43.                 wait()
  44.                 stringValue.TextTransparency = i/50
  45.             end
  46.            
  47.             wait(30)
  48.            
  49.             for i = 0, 50 do
  50.  
  51.                 wait()
  52.                 stringValue.TextTransparency = i/50
  53.             end
  54.            
  55.             stringValue:Destroy()
  56.            
  57.            
  58.         else
  59.  
  60.             warn(errormsg2)
  61.             stringValue:Destroy()          
  62.         end    
  63.     else
  64.  
  65.         warn(errormsg)
  66.         stringValue:Destroy()      
  67.     end
  68. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement