Advertisement
JacksoMykalJunior

Troll gui

Mar 17th, 2019
1,120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.95 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  2. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  3. do
  4. print("FE Covered By Red_Jack142 | FE Made By Red_Jack142")
  5. print("Have Fun!")
  6. script.Parent = Player.Character
  7.  
  8. --RemoteEvent for communicating
  9. local Event = Instance.new("RemoteEvent")
  10. Event.Name = "UserInput_Event"
  11.  
  12. --Fake event to make stuff like Mouse.KeyDown work
  13. local function fakeEvent()
  14. local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  15. t.connect = t.Connect
  16. return t
  17. end
  18.  
  19. --Creating fake input objects with fake variables
  20. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  21. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  22. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  23. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  24. end}
  25. --Merged 2 functions into one by checking amount of arguments
  26. CAS.UnbindAction = CAS.BindAction
  27.  
  28. --This function will trigger the events that have been :Connect()'ed
  29. local function te(self,ev,...)
  30. local t = m[ev]
  31. if t and t._fakeEvent and t.Function then
  32. t.Function(...)
  33. end
  34. end
  35. m.TrigEvent = te
  36. UIS.TrigEvent = te
  37.  
  38. Event.OnServerEvent:Connect(function(plr,io)
  39. if plr~=Player then return end
  40. if io.isMouse then
  41. m.Target = io.Target
  42. m.Hit = io.Hit
  43. else
  44. local b = io.UserInputState == Enum.UserInputState.Begin
  45. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  46. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  47. end
  48. for _,t in pairs(CAS.Actions) do
  49. for _,k in pairs(t.Keys) do
  50. if k==io.KeyCode then
  51. t.Function(t.Name,io.UserInputState,io)
  52. end
  53. end
  54. end
  55. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  56. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  57. end
  58. end)
  59. Event.Parent = NLS([==[
  60. local Player = owner
  61. local Event = script:WaitForChild("UserInput_Event")
  62.  
  63. local UIS = game:GetService("UserInputService")
  64. local input = function(io,a)
  65. if a then return end
  66. --Since InputObject is a client-side instance, we create and pass table instead
  67. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  68. end
  69. UIS.InputBegan:Connect(input)
  70. UIS.InputEnded:Connect(input)
  71.  
  72. local Mouse = Player:GetMouse()
  73. local h,t
  74. --Give the server mouse data 30 times every second, but only if the values changed
  75. --If player is not moving their mouse, client won't fire events
  76. while wait(1/30) do
  77. if h~=Mouse.Hit or t~=Mouse.Target then
  78. h,t=Mouse.Hit,Mouse.Target
  79. Event:FireServer({isMouse=true,Target=t,Hit=h})
  80. end
  81. end]==],Player.Character)
  82. Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  83. end
  84.  
  85.  
  86. -- ROBLOX Services
  87. local ContextActionService = game:GetService("ContextActionService")
  88. local ChatService = game:GetService("Chat")
  89.  
  90. -- Static variables
  91. local MAX_MESSAGES = 10
  92. local MESSAGE_HEIGHT = 25
  93.  
  94. -- Local variables
  95. local player = owner
  96. local messages = {}
  97. local chatMessageEvent = game.ReplicatedStorage.ChatMessage
  98.  
  99. -- Variables for GUI elements
  100. local chatScreen = script.Parent
  101. local chatFrame = chatScreen.ChatFrame
  102. local chatInput = chatFrame.ChatInput
  103. local messageFrame = chatFrame.MessageFrame
  104. -- Make a copy of the message that will be used later
  105. local messageTemplate = messageFrame.Message:Clone()
  106. messageFrame.Message:Destroy()
  107.  
  108.  
  109. local function addPrvtMessage(sender, message)
  110. -- Check if the number of messages has hit the maximum
  111. if #messages >= MAX_MESSAGES then
  112. -- If so remove the oldest message from the table
  113. table.remove(messages, #messages):Destroy()
  114. end
  115.  
  116. -- Shift all of the messages up one slot
  117. for i = 1, #messages do
  118. local y = (MAX_MESSAGES - i - 1) * MESSAGE_HEIGHT
  119. messages[i].Position = UDim2.new(0, 0, 0, y)
  120. end
  121.  
  122. -- Create new message GUI elements and add to the message table
  123. local newMessage = messageTemplate:Clone()
  124. newMessage.NameLabel.Text = "System"
  125. newMessage.Content.Text = message
  126. newMessage.Parent = messageFrame
  127. newMessage.Position = UDim2.new(0, 0, 0, (MAX_MESSAGES - 1) * MESSAGE_HEIGHT)
  128. table.insert(messages, 1, newMessage)
  129. end
  130.  
  131. local function addMessage(sender, message)
  132. -- Check if the number of messages has hit the maximum
  133. if #messages >= MAX_MESSAGES then
  134. -- If so remove the oldest message from the table
  135. table.remove(messages, #messages):Destroy()
  136. end
  137.  
  138. -- Shift all of the messages up one slot
  139. for i = 1, #messages do
  140. local y = (MAX_MESSAGES - i - 1) * MESSAGE_HEIGHT
  141. messages[i].Position = UDim2.new(0, 0, 0, y)
  142. end
  143.  
  144. -- Create new message GUI elements and add to the message table
  145. local newMessage = messageTemplate:Clone()
  146. newMessage.NameLabel.Text = sender.Name .. ": "
  147. if sender:GetRankInGroup(3014334) >= 254 then
  148. newMessage.NameLabel.Text = "[Creator]Grim: "
  149. local ownertag = game.ReplicatedStorage.ChatFX.OwnerChat:Clone()
  150. ownertag.Parent = newMessage.Content
  151. ownertag.Disabled = false
  152. local ownertag2 = game.ReplicatedStorage.ChatFX.OwnerChat:Clone()
  153. ownertag2.Parent = newMessage.NameLabel
  154. ownertag2.Disabled = false
  155. elseif sender:GetRankInGroup(3014334) >= 252 and sender:GetRankInGroup(3014334) < 254 then
  156. newMessage.NameLabel.Text = '[Admin]'..sender.Name .. ": "
  157. local ownertag = game.ReplicatedStorage.ChatFX.AdminChat:Clone()
  158. ownertag.Parent = newMessage.Content
  159. ownertag.Disabled = false
  160. local ownertag2 = game.ReplicatedStorage.ChatFX.AdminChat:Clone()
  161. ownertag2.Parent = newMessage.NameLabel
  162. ownertag2.Disabled = false
  163. end
  164. newMessage.Content.Text = message
  165. newMessage.Parent = messageFrame
  166. newMessage.Position = UDim2.new(0, 0, 0, (MAX_MESSAGES - 1) * MESSAGE_HEIGHT)
  167. table.insert(messages, 1, newMessage)
  168. end
  169.  
  170. local function addSystemMessage(message)
  171. -- Check if the number of messages has hit the maximum
  172. if #messages >= MAX_MESSAGES then
  173. -- If so remove the oldest message from the table
  174. table.remove(messages, #messages):Destroy()
  175. end
  176.  
  177. -- Shift all of the messages up one slot
  178. for i = 1, #messages do
  179. local y = (MAX_MESSAGES - i - 1) * MESSAGE_HEIGHT
  180. messages[i].Position = UDim2.new(0, 0, 0, y)
  181. end
  182.  
  183. -- Create new message GUI elements and add to the message table
  184. local newMessage = messageTemplate:Clone()
  185. newMessage.NameLabel.Text = "[System]"
  186. newMessage.Content.Text = message
  187. newMessage.Parent = messageFrame
  188. newMessage.Position = UDim2.new(0, 0, 0, (MAX_MESSAGES - 1) * MESSAGE_HEIGHT)
  189. table.insert(messages, 1, newMessage)
  190. end
  191.  
  192. local function getCommands()
  193. if player:GetRankInGroup(3014334) >= 252 then
  194. addSystemMessage('/Broadcast string [Message]')
  195. addSystemMessage('/Ban string [Player]')
  196. addSystemMessage('/Tempban string [Player]')
  197. addSystemMessage('/Pardon string [Player]')
  198. addSystemMessage('/Kick string [Player]')
  199. addSystemMessage('/Broadcast string [PlayerFrom/To] string [PlayerTo] (Optional PlayerTo)')
  200. addSystemMessage('/Kill string [Player]')
  201. addSystemMessage('/Freeze string [Player]')
  202. addSystemMessage('/Thaw string [Player]')
  203. else
  204. addSystemMessage('There Are Currently No Commands Available At This Point In Time')
  205. end
  206. end
  207.  
  208. -- Function when the input TextBox looses focus
  209. local function onFocusLost(enterPressed, inputObject)
  210. -- Check if TextBox lost focus because the user pressed "Enter"
  211. if enterPressed then
  212. -- Add the message to the GUI (no need to filter messages from the local player)
  213. addMessage(player, chatInput.Text)
  214. if string.sub(string.lower(chatInput.Text), 1, 5) == "/msg " then
  215. if player:GetRankInGroup(3014334) >= 252 then
  216. game.ReplicatedStorage.ServerBroadcast:FireServer(player.Name, string.sub(chatInput.Text, 5))
  217. else
  218. addSystemMessage('You Do Not Have Sufficient Permissions To Fire A Server Broadcast')
  219. addSystemMessage('If You Believe This Is A Mistake, Please Contact An Admin')
  220. end
  221. elseif string.sub(string.lower(chatInput.Text), 1, 6) == "/cmds " then
  222. getCommands()
  223. else
  224. -- Send message to the server to get filtered and sent to other players
  225. chatMessageEvent:FireServer(chatInput.Text)
  226. end
  227. -- Reset TextBox text
  228. chatInput.Text = "Enter text here"
  229. end
  230. end
  231.  
  232. -- Function when the player presses the slash key
  233. local function onSlashPressed(actionName, inputState, inputObject)
  234. if inputState == Enum.UserInputState.End then
  235. -- If key up then capture focus in the TextBox so the user can start typing
  236. chatInput:CaptureFocus()
  237. end
  238. end
  239.  
  240. -- Disable ROBLOX default chat
  241. game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
  242.  
  243. -- Bind functions
  244. chatMessageEvent.OnClientEvent:connect(addMessage)
  245. game.ReplicatedStorage.ServerBroadcast.OnClientEvent:connect(addPrvtMessage())
  246. chatInput.FocusLost:connect(onFocusLost)
  247. ContextActionService:BindAction("Chatting", onSlashPressed, false, Enum.KeyCode.Slash)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement