Advertisement
memberhero

Basstracker's FE Converter

Feb 3rd, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 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. local Mouse,mouse,UserInputService,ContextActionService = owner
  4. do
  5. print("FE Compatibility code by Mokiros Edited by basstracker1970")
  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. elseif io.UserInputType == Enum.UserInputType.MouseButton1 then
  44. if io.UserInputState == Enum.UserInputState.Begin then
  45. m:TrigEvent("Button1Down")
  46. else
  47. m:TrigEvent("Button1Up")
  48. end
  49. else
  50. for n,t in pairs(CAS.Actions) do
  51. for _,k in pairs(t.Keys) do
  52. if k==io.KeyCode then
  53. t.Function(t.Name,io.UserInputState,io)
  54. end
  55. end
  56. end
  57. if io.UserInputState == Enum.UserInputState.Begin then
  58. m:TrigEvent("KeyDown",io.KeyCode.Name:lower())
  59. UIS:TrigEvent("InputBegan",io,false)
  60. else
  61. m:TrigEvent("KeyUp",io.KeyCode.Name:lower())
  62. UIS:TrigEvent("InputEnded",io,false)
  63. end
  64. end
  65. end)
  66. Event.Parent = NLS([==[
  67. local Player = game:GetService("Players").LocalPlayer
  68. local Event = script:WaitForChild("UserInput_Event")
  69.  
  70. local UIS = game:GetService("UserInputService")
  71. local input = function(io,a)
  72. if a then return end
  73. --Since InputObject is a client-side instance, we create and pass table instead
  74. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  75. end
  76. UIS.InputBegan:Connect(input)
  77. UIS.InputEnded:Connect(input)
  78.  
  79. local Mouse = Player:GetMouse()
  80. local h,t
  81. --Give the server mouse data 30 times every second, but only if the values changed
  82. --If player is not moving their mouse, client won't fire events
  83. while wait(1/30) do
  84. if h~=Mouse.Hit or t~=Mouse.Target then
  85. h,t=Mouse.Hit,Mouse.Target
  86. Event:FireServer({isMouse=true,Target=t,Hit=h})
  87. end
  88. end]==],Player.Character)
  89. Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  90.  
  91. end
  92. wait(0.2)
  93. --Paste This Above Any Script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement