Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --https://github.com/Mokiros/roblox-FE-compatibility
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player,Mouse,mouse,UserInputService,ContextActionService = owner
- local RealPlayer = Player
- 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
- local NodesPerStep = 30
- plr = game:GetService("Players").LocalPlayer
- char = plr.Character
- m = plr:GetMouse()
- human = char.Humanoid
- torso = char.Torso
- root = char.HumanoidRootPart
- lleg = char["Left Leg"]
- rleg = char["Right Leg"]
- larm = char["Left Arm"]
- rarm = char["Right Arm"]
- head = char.Head
- lshold = torso["Left Shoulder"]
- rshold = torso["Right Shoulder"]
- neck = torso.Neck
- lhip = torso["Left Hip"]
- rhip = torso["Right Hip"]
- lscf = lshold.C0
- rscf = rshold.C0
- ncf = neck.C0
- lhcf = lhip.C0
- rhcf = rhip.C0
- rad = math.rad
- random = math.random
- sin = math.sin
- cos = math.cos
- hurt = false
- local Maze = {}
- function Maze:New(xSize, ySize)
- local Cells = {}
- local IDs = {}
- local ID = 1
- for x = 0, xSize+1 do
- Cells[x] = {}
- for y = 0, ySize+1 do
- Cells[x][y] = {
- ID = ID;
- X = x;
- Y = y;
- Edge = (x == 0 or y == 0 or x==xSize+1 or y == ySize+1)
- }
- IDs[ID] = Cells[x][y]
- ID = ID + 1
- end
- end
- local NewMaze = {
- Cells = Cells;
- IDs = IDs;
- }
- setmetatable(NewMaze, {
- __index = Maze;
- })
- return NewMaze
- end
- function Maze:NewWalls(x, y)
- local Walls = {}
- if (x == self.Finish.X and y == self.Finish.Y) or
- (x == self.Start.X and y == self.Start.Y) then
- if x == #self.Cells then
- Walls[1] = {self.Cells[x][y].ID, self.Cells[x-1][y].ID}
- Walls[2] = {self.Cells[x][y].ID, false}
- else
- Walls[1] = {self.Cells[x][y].ID, self.Cells[x+1][y].ID}
- Walls[2] = {self.Cells[x][y].ID, false}
- end
- if y == #self.Cells[x] then
- Walls[3] = {self.Cells[x][y].ID, self.Cells[x][y-1].ID}
- Walls[4] = {self.Cells[x][y].ID, false}
- else
- Walls[3] = {self.Cells[x][y].ID, self.Cells[x][y+1].ID}
- Walls[4] = {self.Cells[x][y].ID, false}
- end
- else
- Walls[1] = {self.Cells[x][y].ID, self.Cells[x-1][y].ID}
- Walls[2] = {self.Cells[x][y].ID, self.Cells[x+1][y].ID}
- Walls[3] = {self.Cells[x][y].ID, self.Cells[x][y-1].ID}
- Walls[4] = {self.Cells[x][y].ID, self.Cells[x][y+1].ID}
- end
- return Walls
- end
- function Maze:Generate(start, finish, scale, height)
- self.Finish = finish
- self.Start = start
- self.Scale = scale
- self.Height = height
- self.Model = Instance.new("Model")
- self.Model.Name = "Maze"
- local Walls = self:NewWalls(start.X, start.Y)
- local PermWalls = {}
- local PermCells = {[self.Cells[start.X][start.Y].ID] = true}
- local Rand = math.random
- local function MainLoop()
- while wait() do
- for i = 1, NodesPerStep do
- if not next(Walls, Key) then
- return nil
- end
- local Key = Rand(1, #Walls)
- local w = Walls[Key]
- table.remove(Walls,Key)
- local Other
- local Self
- if PermCells[w[1]] then
- if PermCells[w[2]] then
- PermWalls[#PermWalls+1] = w
- else
- Other = w[2]
- Self = w[1]
- end
- else
- Other = w[1]
- Self = w[2]
- end
- if Other then
- PermCells[Other] = true
- if self.IDs[Other].Edge then
- PermWalls[#PermWalls+1] = w
- else
- for _, Wall in pairs(self:NewWalls(self.IDs[Other].X, self.IDs[Other].Y)) do
- if Wall[2] ~= Self then
- Walls[#Walls+1] = Wall
- end
- end
- end
- end
- end
- end
- end
- MainLoop()
- for _, Wall in pairs(PermWalls) do
- self:CreateWall(Wall[1], Wall[2])
- end
- local xMax = ((#self.Cells - 1))*scale
- local yMax = ((#self.Cells[1] - 1))*scale
- local Floor = Instance.new("Part")
- Floor.Anchored = true
- Floor.BrickColor = BrickColor.new('Bright green')
- Floor.Material = "Grass"
- Floor.Name = "MainBase"
- Floor.Size = Vector3.new(xMax+2, 1.2, yMax+2)
- Floor.Position = Vector3.new(xMax/2+scale/2,-0.4,yMax/2+scale/2)
- Floor.Parent = self.Model
- end
- function Maze:CreateWall(id1, id2)
- local Wall = Instance.new "Part"
- Wall.Anchored = true
- Wall.Name = "Walls"
- Wall.Size = Vector3.new(self.Scale, self.Height, 2)
- local n1 = self.IDs[id1]
- local n2 = self.IDs[id2]
- Wall.CFrame = CFrame.new(
- Vector3.new(n1.X, self.Height/2, n1.Y),
- Vector3.new(n2.X, self.Height/2, n2.Y)
- )
- Wall.Position = Vector3.new((n1.X + n2.X)*self.Scale/2, self.Height/2, (n1.Y + n2.Y)*self.Scale/2)
- Wall.Parent = self.Model
- end
- local m = Maze:New(25,25)
- m:Generate(Vector2.new(1,25), Vector2.new(50,50), 20, 25)
- m.Model.Parent = workspace
- m.Model:MoveTo(workspace:FindFirstChild('Base').Position + Vector3.new(0,65,0))
- for _,c in pairs(m.Model:GetChildren()) do
- if c:IsA('Part') then
- if c.Name == "Walls" then
- c.Anchored = true
- c.CanCollide = false
- c.Name ="Walls"
- c.Transparency = 1
- c.TopSurface = 0
- c.BottomSurface = 0
- c.BrickColor = BrickColor.new('Daisy orange')
- c.Material = "Cobblestone"
- end
- end
- end
- thing = Instance.new('Part', char.Torso)
- thing.Anchored = false
- thing.CanCollide = false
- thing.Transparency = 1
- thing.Name = "Trigger"
- thing.Size = Vector3.new(225, 0, 225)
- thing.Touched:connect(function(hit)
- if hit.Name == "Walls" then
- hit.CanCollide = true
- hit.Transparency = 0
- local s = Instance.new("SelectionBox", char)
- local lasso = Instance.new("SelectionPartLasso",s)
- lasso.Humanoid = char.Humanoid
- lasso.Part = hit
- end
- end)
- thing.TouchEnded:connect(function(unhit)
- if unhit.Name == "Walls" then
- unhit.CanCollide = false
- unhit.Transparency = 1
- for _,c in pairs(char:GetChildren()) do
- if c:IsA('SelectionBox') then
- c:Destroy()
- end
- end
- end
- end)
- char.Torso.CFrame = CFrame.new(0,125,0)
- char.Archivable = true
- game:GetService("RunService").RenderStepped:connect(function()
- thing.CFrame = char.Torso.CFrame
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement