SHOW:
|
|
- or go back to the newest paste.
| 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 | local chatMessageEvent = game.ReplicatedStorage.ChatMessage | |
| 19 | ||
| 20 | -- Variables for GUI elements | |
| 21 | local chatScreen = script.Parent | |
| 22 | local chatFrame = chatScreen.ChatFrame | |
| 23 | local chatInput = chatFrame.ChatInput | |
| 24 | local messageFrame = chatFrame.MessageFrame | |
| 25 | -- Make a copy of the message that will be used later | |
| 26 | local messageTemplate = messageFrame.Message:Clone() | |
| 27 | messageFrame.Message:Destroy() | |
| 28 | ||
| 29 | ||
| 30 | local function addPrvtMessage(sender, message) | |
| 31 | -- Check if the number of messages has hit the maximum | |
| 32 | if #messages >= MAX_MESSAGES then | |
| 33 | -- If so remove the oldest message from the table | |
| 34 | table.remove(messages, #messages):Destroy() | |
| 35 | end | |
| 36 | ||
| 37 | -- Shift all of the messages up one slot | |
| 38 | for i = 1, #messages do | |
| 39 | local y = (MAX_MESSAGES - i - 1) * MESSAGE_HEIGHT | |
| 40 | messages[i].Position = UDim2.new(0, 0, 0, y) | |
| 41 | end | |
| 42 | ||
| 43 | -- Create new message GUI elements and add to the message table | |
| 44 | local newMessage = messageTemplate:Clone() | |
| 45 | newMessage.NameLabel.Text = "System" | |
| 46 | newMessage.Content.Text = message | |
| 47 | newMessage.Parent = messageFrame | |
| 48 | newMessage.Position = UDim2.new(0, 0, 0, (MAX_MESSAGES - 1) * MESSAGE_HEIGHT) | |
| 49 | table.insert(messages, 1, newMessage) | |
| 50 | end | |
| 51 | ||
| 52 | local function addMessage(sender, message) | |
| 53 | -- Check if the number of messages has hit the maximum | |
| 54 | if #messages >= MAX_MESSAGES then | |
| 55 | -- If so remove the oldest message from the table | |
| 56 | table.remove(messages, #messages):Destroy() | |
| 57 | end | |
| 58 | ||
| 59 | -- Shift all of the messages up one slot | |
| 60 | for i = 1, #messages do | |
| 61 | local y = (MAX_MESSAGES - i - 1) * MESSAGE_HEIGHT | |
| 62 | messages[i].Position = UDim2.new(0, 0, 0, y) | |
| 63 | end | |
| 64 | ||
| 65 | -- Create new message GUI elements and add to the message table | |
| 66 | local newMessage = messageTemplate:Clone() | |
| 67 | newMessage.NameLabel.Text = sender.Name .. ": " | |
| 68 | if sender:GetRankInGroup(3014334) >= 254 then | |
| 69 | newMessage.NameLabel.Text = "[Creator]Grim: " | |
| 70 | local ownertag = game.ReplicatedStorage.ChatFX.OwnerChat:Clone() | |
| 71 | ownertag.Parent = newMessage.Content | |
| 72 | ownertag.Disabled = false | |
| 73 | local ownertag2 = game.ReplicatedStorage.ChatFX.OwnerChat:Clone() | |
| 74 | ownertag2.Parent = newMessage.NameLabel | |
| 75 | ownertag2.Disabled = false | |
| 76 | elseif sender:GetRankInGroup(3014334) >= 252 and sender:GetRankInGroup(3014334) < 254 then | |
| 77 | newMessage.NameLabel.Text = '[Admin]'..sender.Name .. ": " | |
| 78 | local ownertag = game.ReplicatedStorage.ChatFX.AdminChat:Clone() | |
| 79 | ownertag.Parent = newMessage.Content | |
| 80 | ownertag.Disabled = false | |
| 81 | local ownertag2 = game.ReplicatedStorage.ChatFX.AdminChat:Clone() | |
| 82 | ownertag2.Parent = newMessage.NameLabel | |
| 83 | ownertag2.Disabled = false | |
| 84 | end | |
| 85 | newMessage.Content.Text = message | |
| 86 | newMessage.Parent = messageFrame | |
| 87 | newMessage.Position = UDim2.new(0, 0, 0, (MAX_MESSAGES - 1) * MESSAGE_HEIGHT) | |
| 88 | table.insert(messages, 1, newMessage) | |
| 89 | end | |
| 90 | ||
| 91 | local function addSystemMessage(message) | |
| 92 | -- Check if the number of messages has hit the maximum | |
| 93 | if #messages >= MAX_MESSAGES then | |
| 94 | -- If so remove the oldest message from the table | |
| 95 | table.remove(messages, #messages):Destroy() | |
| 96 | end | |
| 97 | ||
| 98 | -- Shift all of the messages up one slot | |
| 99 | for i = 1, #messages do | |
| 100 | local y = (MAX_MESSAGES - i - 1) * MESSAGE_HEIGHT | |
| 101 | messages[i].Position = UDim2.new(0, 0, 0, y) | |
| 102 | end | |
| 103 | ||
| 104 | -- Create new message GUI elements and add to the message table | |
| 105 | local newMessage = messageTemplate:Clone() | |
| 106 | newMessage.NameLabel.Text = "[System]" | |
| 107 | newMessage.Content.Text = message | |
| 108 | newMessage.Parent = messageFrame | |
| 109 | newMessage.Position = UDim2.new(0, 0, 0, (MAX_MESSAGES - 1) * MESSAGE_HEIGHT) | |
| 110 | table.insert(messages, 1, newMessage) | |
| 111 | end | |
| 112 | ||
| 113 | local function getCommands() | |
| 114 | if player:GetRankInGroup(3014334) >= 252 then | |
| 115 | addSystemMessage('/Broadcast string [Message]')
| |
| 116 | addSystemMessage('/Ban string [Player]')
| |
| 117 | addSystemMessage('/Tempban string [Player]')
| |
| 118 | addSystemMessage('/Pardon string [Player]')
| |
| 119 | addSystemMessage('/Kick string [Player]')
| |
| 120 | addSystemMessage('/Broadcast string [PlayerFrom/To] string [PlayerTo] (Optional PlayerTo)')
| |
| 121 | addSystemMessage('/Kill string [Player]')
| |
| 122 | addSystemMessage('/Freeze string [Player]')
| |
| 123 | addSystemMessage('/Thaw string [Player]')
| |
| 124 | else | |
| 125 | addSystemMessage('There Are Currently No Commands Available At This Point In Time')
| |
| 126 | end | |
| 127 | end | |
| 128 | ||
| 129 | -- Function when the input TextBox looses focus | |
| 130 | local function onFocusLost(enterPressed, inputObject) | |
| 131 | -- Check if TextBox lost focus because the user pressed "Enter" | |
| 132 | if enterPressed then | |
| 133 | -- Add the message to the GUI (no need to filter messages from the local player) | |
| 134 | addMessage(player, chatInput.Text) | |
| 135 | if string.sub(string.lower(chatInput.Text), 1, 5) == "/msg " then | |
| 136 | if player:GetRankInGroup(3014334) >= 252 then | |
| 137 | game.ReplicatedStorage.ServerBroadcast:FireServer(player.Name, string.sub(chatInput.Text, 5)) | |
| 138 | else | |
| 139 | addSystemMessage('You Do Not Have Sufficient Permissions To Fire A Server Broadcast')
| |
| 140 | addSystemMessage('If You Believe This Is A Mistake, Please Contact An Admin')
| |
| 141 | end | |
| 142 | elseif string.sub(string.lower(chatInput.Text), 1, 6) == "/cmds " then | |
| 143 | getCommands() | |
| 144 | else | |
| 145 | -- Send message to the server to get filtered and sent to other players | |
| 146 | chatMessageEvent:FireServer(chatInput.Text) | |
| 147 | end | |
| 148 | -- Reset TextBox text | |
| 149 | chatInput.Text = "Enter text here" | |
| 150 | end | |
| 151 | end | |
| 152 | ||
| 153 | -- Function when the player presses the slash key | |
| 154 | local function onSlashPressed(actionName, inputState, inputObject) | |
| 155 | if inputState == Enum.UserInputState.End then | |
| 156 | -- If key up then capture focus in the TextBox so the user can start typing | |
| 157 | chatInput:CaptureFocus() | |
| 158 | end | |
| 159 | end | |
| 160 | ||
| 161 | -- Disable ROBLOX default chat | |
| 162 | game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false) | |
| 163 | ||
| 164 | -- Bind functions | |
| 165 | chatMessageEvent.OnClientEvent:connect(addMessage) | |
| 166 | game.ReplicatedStorage.ServerBroadcast.OnClientEvent:connect(addPrvtMessage()) | |
| 167 | chatInput.FocusLost:connect(onFocusLost) | |
| 168 | ContextActionService:BindAction("Chatting", onSlashPressed, false, Enum.KeyCode.Slash) |