Advertisement
PR0J3CT11

Untitled

Aug 3rd, 2019
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --https://github.com/Mokiros/roblox-FE-compatibility
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,game,owner = owner,game
  4. local RealPlayer = Player
  5. do print("FE Compatibility code V2 by Mokiros")local RealPlayer=RealPlayer;script.Parent=RealPlayer.Character;local a=function(b)b[1].f[b[2]]=nil end;local c={__index={disconnect=a,Disconnect=a}}local d={__index={Connect=function(b,e)local f=tostring(math.random(0,10000))while b.f[f]do f=tostring(math.random(0,10000))end;b.f[f]=e;return setmetatable({b,f},c)end}}d.__index.connect=d.__index.Connect;local function g()return setmetatable({f={}},d)end;local h={Hit=CFrame.new(),KeyUp=g(),KeyDown=g(),Button1Up=g(),Button1Down=g(),Button2Up=g(),Button2Down=g()}h.keyUp=h.KeyUp;h.keyDown=h.KeyDown;local i={InputBegan=g(),InputEnded=g()}local CAS={Actions={},BindAction=function(self,j,k,l,...)CAS.Actions[j]=k and{Name=j,Function=k,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function m(self,n,...)for o,e in pairs(self[n].f)do e(...)end end;h.T=m;i.T=m;local p=Instance.new("RemoteEvent")p.Name="UserInput_Event"p.OnServerEvent:Connect(function(q,r)if q~=RealPlayer then return end;h.Target=r.e;h.Hit=r.d;if not r.f then local s=r.c==Enum.UserInputState.Begin;if r.b==Enum.UserInputType.MouseButton1 then return h:T(s and"Button1Down"or"Button1Up")end;if r.b==Enum.UserInputType.MouseButton2 then return h:T(s and"Button2Down"or"Button2Up")end;for o,t in pairs(CAS.Actions)do for o,u in pairs(t.Keys)do if u==r.a then t.Function(t.Name,r.c,r)end end end;h:T(s and"KeyDown"or"KeyUp",r.a.Name:lower())i:T(s and"InputBegan"or"InputEnded",r,false)end end)p.Parent=NLS([==[local a=script:WaitForChild("UserInput_Event")local b=owner:GetMouse()local c=game:GetService("UserInputService")local d=function(e,f)if f then return end;a:FireServer({a=e.KeyCode,b=e.UserInputType,c=e.UserInputState,d=b.Hit,e=b.Target})end;c.InputBegan:Connect(d)c.InputEnded:Connect(d)local g,h;local i=game:GetService("RunService").Heartbeat;while true do if g~=b.Hit or h~=b.Target then g,h=b.Hit,b.Target;a:FireServer({f=1,Target=h,d=g})end;for j=1,2 do i:Wait()end end]==],script)local v=game;local w={__index=function(self,u)local x=rawget(self,"_RealService")if x then return typeof(x[u])=="function"and function(o,...)return x[u](x,...)end or x[u]end end,__newindex=function(self,u,y)local x=rawget(self,"_RealService")if x then x[u]=y end end}local function z(t,A)t._RealService=typeof(A)=="string"and v:GetService(A)or A;return setmetatable(t,w)end;local B={GetService=function(self,x)return rawget(self,x)or v:GetService(x)end,Players=z({LocalPlayer=z({GetMouse=function(self)return h end},Player)},"Players"),UserInputService=z(i,"UserInputService"),ContextActionService=z(CAS,"ContextActionService"),RunService=z({_btrs={},RenderStepped=v:GetService("RunService").Heartbeat,BindToRenderStep=function(self,j,o,k)self._btrs[j]=self.Heartbeat:Connect(k)end,UnbindFromRenderStep=function(self,j)self._btrs[j]:Disconnect()end},"RunService")}rawset(B.Players,"localPlayer",B.Players.LocalPlayer)B.service=B.GetService;z(B,game)game,owner=B,B.Players.LocalPlayer end
  6.  
  7. -- ROBLOX Services
  8. local ContextActionService = game:GetService("ContextActionService")
  9. local ChatService = game:GetService("Chat")
  10.  
  11. -- Static variables
  12. local MAX_MESSAGES = 10
  13. local MESSAGE_HEIGHT = 25
  14.  
  15. -- Local variables
  16. local player = game.Players.LocalPlayer
  17. local messages = {}
  18.  
  19. -- Variables for GUI elements
  20. local chatScreen = script.Parent
  21. local chatFrame = chatScreen.ChatFrame
  22. local chatInput = chatFrame.ChatInput
  23. local messageFrame = chatFrame.MessageFrame
  24. -- Make a copy of the message that will be used later
  25. local messageTemplate = messageFrame.Message:Clone()
  26. messageFrame.Message:Destroy()
  27.  
  28.  
  29. local function addPrvtMessage(sender, message)
  30.     -- Check if the number of messages has hit the maximum
  31.     if #messages >= MAX_MESSAGES then
  32.         -- If so remove the oldest message from the table
  33.         table.remove(messages, #messages):Destroy()
  34.     end
  35.    
  36.     -- Shift all of the messages up one slot
  37.     for i = 1, #messages do
  38.         local y = (MAX_MESSAGES - i - 1) * MESSAGE_HEIGHT
  39.         messages[i].Position = UDim2.new(0, 0, 0, y)
  40.     end
  41.    
  42.     -- Create new message GUI elements and add to the message table
  43.     local newMessage = messageTemplate:Clone()
  44.     newMessage.NameLabel.Text = "System"
  45.     newMessage.Content.Text = message
  46.     newMessage.Parent = messageFrame
  47.     newMessage.Position = UDim2.new(0, 0, 0, (MAX_MESSAGES - 1) * MESSAGE_HEIGHT)
  48.     table.insert(messages, 1, newMessage)
  49. end
  50.  
  51. local function addMessage(sender, message)
  52.     -- Check if the number of messages has hit the maximum
  53.     if #messages >= MAX_MESSAGES then
  54.         -- If so remove the oldest message from the table
  55.         table.remove(messages, #messages):Destroy()
  56.     end
  57.    
  58.     -- Shift all of the messages up one slot
  59.     for i = 1, #messages do
  60.         local y = (MAX_MESSAGES - i - 1) * MESSAGE_HEIGHT
  61.         messages[i].Position = UDim2.new(0, 0, 0, y)
  62.     end
  63.    
  64.     -- Create new message GUI elements and add to the message table
  65.     local newMessage = messageTemplate:Clone()
  66.     newMessage.NameLabel.Text = sender.Name .. ": "
  67.         if sender:GetRankInGroup(3014334) >= 254 then
  68.             newMessage.NameLabel.Text = "[Creator]Grim: "
  69.             local ownertag = game.ReplicatedStorage.ChatFX.OwnerChat:Clone()
  70.             ownertag.Parent = newMessage.Content
  71.             ownertag.Disabled = false
  72.             local ownertag2 = game.ReplicatedStorage.ChatFX.OwnerChat:Clone()
  73.             ownertag2.Parent = newMessage.NameLabel
  74.             ownertag2.Disabled = false
  75.         elseif sender:GetRankInGroup(3014334) >= 252 and sender:GetRankInGroup(3014334) < 254 then
  76.             newMessage.NameLabel.Text = '[Admin]'..sender.Name .. ": "
  77.             local ownertag = game.ReplicatedStorage.ChatFX.AdminChat:Clone()
  78.             ownertag.Parent = newMessage.Content
  79.             ownertag.Disabled = false
  80.             local ownertag2 = game.ReplicatedStorage.ChatFX.AdminChat:Clone()
  81.             ownertag2.Parent = newMessage.NameLabel
  82.             ownertag2.Disabled = false
  83.         end
  84.     newMessage.Content.Text = message
  85.     newMessage.Parent = messageFrame
  86.     newMessage.Position = UDim2.new(0, 0, 0, (MAX_MESSAGES - 1) * MESSAGE_HEIGHT)
  87.     table.insert(messages, 1, newMessage)
  88. end
  89.  
  90. local function addSystemMessage(message)
  91.     -- Check if the number of messages has hit the maximum
  92.     if #messages >= MAX_MESSAGES then
  93.         -- If so remove the oldest message from the table
  94.         table.remove(messages, #messages):Destroy()
  95.     end
  96.    
  97.     -- Shift all of the messages up one slot
  98.     for i = 1, #messages do
  99.         local y = (MAX_MESSAGES - i - 1) * MESSAGE_HEIGHT
  100.         messages[i].Position = UDim2.new(0, 0, 0, y)
  101.     end
  102.    
  103.     -- Create new message GUI elements and add to the message table
  104.     local newMessage = messageTemplate:Clone()
  105.     newMessage.NameLabel.Text = "[System]"
  106.     newMessage.Content.Text = message
  107.     newMessage.Parent = messageFrame
  108.     newMessage.Position = UDim2.new(0, 0, 0, (MAX_MESSAGES - 1) * MESSAGE_HEIGHT)
  109.     table.insert(messages, 1, newMessage)
  110. end
  111.  
  112. local function getCommands()
  113.     if player:GetRankInGroup(3014334) >= 252 then
  114.         addSystemMessage('/Broadcast string [Message]')
  115.         addSystemMessage('/Ban string [Player]')
  116.         addSystemMessage('/Tempban string [Player]')
  117.         addSystemMessage('/Pardon string [Player]')
  118.         addSystemMessage('/Kick string [Player]')
  119.         addSystemMessage('/Broadcast string [PlayerFrom/To] string [PlayerTo] (Optional PlayerTo)')
  120.         addSystemMessage('/Kill string [Player]')
  121.         addSystemMessage('/Freeze string [Player]')
  122.         addSystemMessage('/Thaw string [Player]')
  123.     else
  124.         addSystemMessage('There Are Currently No Commands Available At This Point In Time')
  125.     end
  126. end
  127.  
  128. -- Function when the input TextBox looses focus
  129. local function onFocusLost(enterPressed, inputObject)
  130.     -- Check if TextBox lost focus because the user pressed "Enter"
  131.     if enterPressed then
  132.         -- Add the message to the GUI (no need to filter messages from the local player)
  133.         addMessage(player, chatInput.Text)
  134.         if string.sub(string.lower(chatInput.Text), 1, 5) == "/msg " then
  135.             if player:GetRankInGroup(3014334) >= 252 then
  136.                 game.ReplicatedStorage.ServerBroadcast:FireServer(player.Name, string.sub(chatInput.Text, 5))
  137.             else
  138.                 addSystemMessage('You Do Not Have Sufficient Permissions To Fire A Server Broadcast')
  139.                 addSystemMessage('If You Believe This Is A Mistake, Please Contact An Admin')
  140.             end
  141.         elseif string.sub(string.lower(chatInput.Text), 1, 6) == "/cmds " then
  142.             getCommands()
  143.         else
  144.             -- Send message to the server to get filtered and sent to other players
  145.             chatMessageEvent:FireServer(chatInput.Text)
  146.         end
  147.         -- Reset TextBox text
  148.         chatInput.Text = "Enter text here"
  149.     end
  150. end
  151.  
  152. -- Function when the player presses the slash key
  153. local function onSlashPressed(actionName, inputState, inputObject)
  154.     if inputState == Enum.UserInputState.End then
  155.         -- If key up then capture focus in the TextBox so the user can start typing
  156.         chatInput:CaptureFocus()
  157.     end
  158. end
  159.  
  160. -- Disable ROBLOX default chat
  161. game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
  162.  
  163. -- Bind functions
  164. chatMessageEvent.OnClientEvent:connect(addMessage)
  165. game.ReplicatedStorage.ServerBroadcast.OnClientEvent:connect(addPrvtMessage())
  166. chatInput.FocusLost:connect(onFocusLost)
  167. ContextActionService:BindAction("Chatting", onSlashPressed, false, Enum.KeyCode.Slash)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement