Advertisement
PasterXIV

Untitled

Sep 12th, 2019
114
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,Mouse,mouse,UserInputService,ContextActionService = owner
  4. local RealPlayer = Player
  5. do print("FE Compatibility code by Mokiros")local a=RealPlayer;script.Parent=a.Character;local b=Instance.new("RemoteEvent")b.Name="UserInput_Event"local function c()local d={_fakeEvent=true,Functions={},Connect=function(self,e)table.insert(self.Functions,e)end}d.connect=d.Connect;return d end;local f={Target=nil,Hit=CFrame.new(),KeyUp=c(),KeyDown=c(),Button1Up=c(),Button1Down=c(),Button2Up=c(),Button2Down=c()}local g={InputBegan=c(),InputEnded=c()}local CAS={Actions={},BindAction=function(self,h,i,j,...)CAS.Actions[h]=i and{Name=h,Function=i,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function k(self,l,...)local d=f[l]if d and d._fakeEvent then for m,e in pairs(d.Functions)do e(...)end end end;f.TrigEvent=k;g.TrigEvent=k;b.OnServerEvent:Connect(function(n,o)if n~=a then return end;f.Target=o.Target;f.Hit=o.Hit;if not o.isMouse then local p=o.UserInputState==Enum.UserInputState.Begin;if o.UserInputType==Enum.UserInputType.MouseButton1 then return f:TrigEvent(p and"Button1Down"or"Button1Up")end;if o.UserInputType==Enum.UserInputType.MouseButton2 then return f:TrigEvent(p and"Button2Down"or"Button2Up")end;for m,d in pairs(CAS.Actions)do for m,q in pairs(d.Keys)do if q==o.KeyCode then d.Function(d.Name,o.UserInputState,o)end end end;f:TrigEvent(p and"KeyDown"or"KeyUp",o.KeyCode.Name:lower())g:TrigEvent(p and"InputBegan"or"InputEnded",o,false)end end)b.Parent=NLS([==[local a=game:GetService("Players").LocalPlayer;local b=script:WaitForChild("UserInput_Event")local c=a:GetMouse()local d=game:GetService("UserInputService")local e=function(f,g)if g then return end;b:FireServer({KeyCode=f.KeyCode,UserInputType=f.UserInputType,UserInputState=f.UserInputState,Hit=c.Hit,Target=c.Target})end;d.InputBegan:Connect(e)d.InputEnded:Connect(e)local h,i;while wait(1/30)do if h~=c.Hit or i~=c.Target then h,i=c.Hit,c.Target;b:FireServer({isMouse=true,Target=i,Hit=h})end end]==],Player.Character)local r=game;local s={__index=function(self,q)local t=rawget(self,"_RealService")if t then return typeof(t[q])=="function"and function(m,...)return t[q](t,...)end or t[q]end end,__newindex=function(self,q,u)local t=rawget(self,"_RealService")if t then t[q]=u end end}local function v(d,w)d._RealService=typeof(w)=="string"and r:GetService(w)or w;return setmetatable(d,s)end;local x={GetService=function(self,t)return rawget(self,t)or r:GetService(t)end,Players=v({LocalPlayer=v({GetMouse=function(self)return f end},Player)},"Players"),UserInputService=v(g,"UserInputService"),ContextActionService=v(CAS,"ContextActionService"),RunService=v({_btrs={},Soundscape=r:GetService("RunService").Heartbeat,BindToSoundscape=function(self,h,m,i)self._btrs[h]=self.Heartbeat:Connect(i)end,UnbindFromRenderStep=function(self,h)self._btrs[h]:Disconnect()end},"RunService")}rawset(x.Players,"localPlayer",x.Players.LocalPlayer)x.service=x.GetService;v(x,game)game,owner=x,x.Players.LocalPlayer end
  6.  
  7.  
  8. local NodesPerStep = 30
  9.  
  10. plr = game:GetService("Players").LocalPlayer
  11. char = plr.Character
  12. m = plr:GetMouse()
  13. human = char.Humanoid
  14. torso = char.Torso
  15. root = char.HumanoidRootPart
  16. lleg = char["Left Leg"]
  17. rleg = char["Right Leg"]
  18. larm = char["Left Arm"]
  19. rarm = char["Right Arm"]
  20. head = char.Head
  21. lshold = torso["Left Shoulder"]
  22. rshold = torso["Right Shoulder"]
  23. neck = torso.Neck
  24. lhip = torso["Left Hip"]
  25. rhip = torso["Right Hip"]
  26. lscf = lshold.C0
  27. rscf = rshold.C0
  28. ncf = neck.C0
  29. lhcf = lhip.C0
  30. rhcf = rhip.C0
  31. rad = math.rad
  32. random = math.random
  33. sin = math.sin
  34. cos = math.cos
  35. hurt = false
  36.  
  37. local Maze = {}
  38. function Maze:New(xSize, ySize)
  39. local Cells = {}
  40. local IDs = {}
  41. local ID = 1
  42. for x = 0, xSize+1 do
  43. Cells[x] = {}
  44. for y = 0, ySize+1 do
  45. Cells[x][y] = {
  46. ID = ID;
  47. X = x;
  48. Y = y;
  49. Edge = (x == 0 or y == 0 or x==xSize+1 or y == ySize+1)
  50. }
  51. IDs[ID] = Cells[x][y]
  52. ID = ID + 1
  53. end
  54. end
  55. local NewMaze = {
  56. Cells = Cells;
  57. IDs = IDs;
  58. }
  59. setmetatable(NewMaze, {
  60. __index = Maze;
  61. })
  62. return NewMaze
  63. end
  64. function Maze:NewWalls(x, y)
  65. local Walls = {}
  66. if (x == self.Finish.X and y == self.Finish.Y) or
  67. (x == self.Start.X and y == self.Start.Y) then
  68. if x == #self.Cells then
  69. Walls[1] = {self.Cells[x][y].ID, self.Cells[x-1][y].ID}
  70. Walls[2] = {self.Cells[x][y].ID, false}
  71. else
  72. Walls[1] = {self.Cells[x][y].ID, self.Cells[x+1][y].ID}
  73. Walls[2] = {self.Cells[x][y].ID, false}
  74. end
  75. if y == #self.Cells[x] then
  76. Walls[3] = {self.Cells[x][y].ID, self.Cells[x][y-1].ID}
  77. Walls[4] = {self.Cells[x][y].ID, false}
  78. else
  79. Walls[3] = {self.Cells[x][y].ID, self.Cells[x][y+1].ID}
  80. Walls[4] = {self.Cells[x][y].ID, false}
  81. end
  82. else
  83. Walls[1] = {self.Cells[x][y].ID, self.Cells[x-1][y].ID}
  84. Walls[2] = {self.Cells[x][y].ID, self.Cells[x+1][y].ID}
  85. Walls[3] = {self.Cells[x][y].ID, self.Cells[x][y-1].ID}
  86. Walls[4] = {self.Cells[x][y].ID, self.Cells[x][y+1].ID}
  87. end
  88. return Walls
  89. end
  90. function Maze:Generate(start, finish, scale, height)
  91. self.Finish = finish
  92. self.Start = start
  93. self.Scale = scale
  94. self.Height = height
  95. self.Model = Instance.new("Model")
  96. self.Model.Name = "Maze"
  97. local Walls = self:NewWalls(start.X, start.Y)
  98. local PermWalls = {}
  99. local PermCells = {[self.Cells[start.X][start.Y].ID] = true}
  100. local Rand = math.random
  101. local function MainLoop()
  102. while wait() do
  103. for i = 1, NodesPerStep do
  104. if not next(Walls, Key) then
  105. return nil
  106. end
  107. local Key = Rand(1, #Walls)
  108. local w = Walls[Key]
  109. table.remove(Walls,Key)
  110. local Other
  111. local Self
  112. if PermCells[w[1]] then
  113. if PermCells[w[2]] then
  114. PermWalls[#PermWalls+1] = w
  115. else
  116. Other = w[2]
  117. Self = w[1]
  118. end
  119. else
  120. Other = w[1]
  121. Self = w[2]
  122. end
  123. if Other then
  124. PermCells[Other] = true
  125. if self.IDs[Other].Edge then
  126. PermWalls[#PermWalls+1] = w
  127. else
  128. for _, Wall in pairs(self:NewWalls(self.IDs[Other].X, self.IDs[Other].Y)) do
  129. if Wall[2] ~= Self then
  130. Walls[#Walls+1] = Wall
  131. end
  132. end
  133. end
  134. end
  135. end
  136. end
  137. end
  138. MainLoop()
  139. for _, Wall in pairs(PermWalls) do
  140. self:CreateWall(Wall[1], Wall[2])
  141. end
  142. local xMax = ((#self.Cells - 1))*scale
  143. local yMax = ((#self.Cells[1] - 1))*scale
  144. local Floor = Instance.new("Part")
  145. Floor.Anchored = true
  146. Floor.BrickColor = BrickColor.new('Bright green')
  147. Floor.Material = "Grass"
  148. Floor.Name = "MainBase"
  149. Floor.Size = Vector3.new(xMax+2, 1.2, yMax+2)
  150. Floor.Position = Vector3.new(xMax/2+scale/2,-0.4,yMax/2+scale/2)
  151. Floor.Parent = self.Model
  152. end
  153. function Maze:CreateWall(id1, id2)
  154. local Wall = Instance.new "Part"
  155. Wall.Anchored = true
  156. Wall.Name = "Walls"
  157. Wall.Size = Vector3.new(self.Scale, self.Height, 2)
  158. local n1 = self.IDs[id1]
  159. local n2 = self.IDs[id2]
  160. Wall.CFrame = CFrame.new(
  161. Vector3.new(n1.X, self.Height/2, n1.Y),
  162. Vector3.new(n2.X, self.Height/2, n2.Y)
  163. )
  164. Wall.Position = Vector3.new((n1.X + n2.X)*self.Scale/2, self.Height/2, (n1.Y + n2.Y)*self.Scale/2)
  165. Wall.Parent = self.Model
  166. end
  167.  
  168. local m = Maze:New(25,25)
  169. m:Generate(Vector2.new(1,25), Vector2.new(50,50), 20, 25)
  170. m.Model.Parent = workspace
  171. m.Model:MoveTo(workspace:FindFirstChild('Base').Position + Vector3.new(0,65,0))
  172.  
  173. for _,c in pairs(m.Model:GetChildren()) do
  174. if c:IsA('Part') then
  175. if c.Name == "Walls" then
  176. c.Anchored = true
  177. c.CanCollide = false
  178. c.Name ="Walls"
  179. c.Transparency = 1
  180. c.TopSurface = 0
  181. c.BottomSurface = 0
  182. c.BrickColor = BrickColor.new('Daisy orange')
  183. c.Material = "Cobblestone"
  184. end
  185. end
  186. end
  187.  
  188. thing = Instance.new('Part', char.Torso)
  189. thing.Anchored = false
  190. thing.CanCollide = false
  191. thing.Transparency = 1
  192. thing.Name = "Trigger"
  193. thing.Size = Vector3.new(225, 0, 225)
  194.  
  195. thing.Touched:connect(function(hit)
  196. if hit.Name == "Walls" then
  197. hit.CanCollide = true
  198. hit.Transparency = 0
  199. local s = Instance.new("SelectionBox", char)
  200. local lasso = Instance.new("SelectionPartLasso",s)
  201. lasso.Humanoid = char.Humanoid
  202. lasso.Part = hit
  203. end
  204. end)
  205.  
  206. thing.TouchEnded:connect(function(unhit)
  207. if unhit.Name == "Walls" then
  208. unhit.CanCollide = false
  209. unhit.Transparency = 1
  210. for _,c in pairs(char:GetChildren()) do
  211. if c:IsA('SelectionBox') then
  212. c:Destroy()
  213. end
  214. end
  215. end
  216. end)
  217.  
  218. char.Torso.CFrame = CFrame.new(0,125,0)
  219. char.Archivable = true
  220.  
  221. game:GetService("RunService").RenderStepped:connect(function()
  222. thing.CFrame = char.Torso.CFrame
  223. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement