Advertisement
Descaii

MiniMap

Mar 14th, 2014
1,102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.77 KB | None | 0 0
  1. -- Minimap --
  2. Size = 0.15
  3. Parts = {
  4.    
  5. }
  6. Offset = Vector3.new(0,2000,0)
  7. Collidable = false
  8. TouchKill = true
  9. Running = true
  10. DoWait = false
  11. Parenter = script
  12. if script.ClassName == LocalScript then
  13.     Parenter = Instance.new("Script",Workspace)
  14. end
  15. Admins = {"dogwarrior24","Reinitialized"}
  16. AdOB = {}
  17. Base = Instance.new("Part",Parenter)
  18. Base.Name = "a"
  19. Base.Anchored = true
  20. Base.Size = Vector3.new(400,1,400)
  21. Base.Position = Offset-Vector3.new(0,1,0)
  22. Base.Locked = true
  23. function Load(String)
  24.     a,b = ypcall(loadstring(String))
  25.     return a,b
  26. end
  27. function GetRecursiveChildren(Place)
  28.     local Stuff = {}
  29.     function GRC(P)
  30.         for i,v in pairs(P:GetChildren()) do
  31.             ypcall(function()
  32.                 GRC(v)
  33.                 table.insert(Stuff,v)
  34.             end)
  35.         end
  36.     end
  37.     GRC(Place)
  38.     GRC = nil
  39.     return Stuff
  40. end
  41. cy = function()
  42.     local T = tick()
  43.     coroutine.yield(coroutine.resume(coroutine.create(function() end)))
  44.     return tick()-T
  45. end
  46. sleep = function(time)
  47.     if not time or time == 0 then
  48.         time = cy()
  49.     end
  50.     local t = 0
  51.     repeat
  52.         local T = tick()
  53.         coroutine.yield(coroutine.resume(coroutine.create(function() end)))
  54.         t = t + (tick()-T)
  55.     until t >= time
  56.     return t
  57. end
  58. pass = function(func)
  59.     coroutine.yield(coroutine.resume(coroutine.create(func)))
  60.     return func
  61. end
  62. function PosToCF(Pos)
  63.     return CFrame.new(
  64.         Pos.X,
  65.         Pos.Y,
  66.         Pos.Z
  67.     )
  68. end
  69. function GetFullCFrame(CF,Div)
  70.     return CFrame.new(
  71.         (CF.X*Div),
  72.         (CF.Y*Div),
  73.         (CF.Z*Div)
  74.     )*CFrame.Angles(CF:toEulerAnglesXYZ())
  75. end
  76. function GetPosBy(Pos,Amount)
  77.     return Vector3.new(
  78.         Pos.X*Amount,
  79.         Pos.Y*Amount,
  80.         Pos.Z*Amount
  81.     )
  82. end
  83. function Parts:GetParts()
  84.     local STF = {}
  85.     for i,v in pairs(Parts) do
  86.         if type(v) == "table" then
  87.             table.insert(STF,v)
  88.         end
  89.     end
  90.     return STF
  91. end
  92. local SHR = "Enum.PartType."
  93. function TrackParts()
  94.     Base.Position = Offset-Vector3.new(0,1,0)
  95.     for i,v in pairs(Parts) do
  96.         ypcall(function()
  97.             if v.Part:IsDescendantOf(Workspace) then
  98.                 if not v.Dragging then
  99.                     v.Pos.FormFactor = 'Custom'
  100.                     v.Pos.Anchored = true
  101.                     v.Pos.BrickColor = v.Part.BrickColor
  102.                     v.Mesh.Parent = v.Pos
  103.                     v.Pos.Locked = true
  104.                     v.Pos.TopSurface = "Smooth"
  105.                     v.Pos.BottomSurface = "Smooth"
  106.                     for i,d in pairs(v.Other) do
  107.                         if d.SR then
  108.                             d:Update()
  109.                         else
  110.                             d.O:Destroy()
  111.                             table.remove(v.Other,i)
  112.                         end
  113.                     end
  114.                     v.Pos.Transparency = v.Part.Transparency
  115.                     v.Mesh.Scale = Vector3.new(Size,Size,Size)
  116.                     v.Pos.Size = v.Part.Size
  117.                     if Collidable then
  118.                         if v.Part.CanCollide then
  119.                             v.Pos.CanCollide = true
  120.                         else
  121.                             v.Pos.CanCollide = false
  122.                         end
  123.                     else
  124.                         v.Pos.CanCollide = false
  125.                     end
  126.                     if v.Part:findFirstChild("Mesh") then
  127.                         local M = v.Part.Mesh
  128.                         if M.ClassName == "SpecialMesh" then
  129.                             v.Mesh.MeshType = M.MeshType
  130.                             v.Mesh.MeshId = M.MeshId
  131.                             v.Mesh.TextureId = M.TextureId
  132.                             v.Mesh.VertexColor = M.VertexColor
  133.                             v.Mesh.Scale = Vector3.new(Size+((M.Scale.X-1)*Size),Size+((M.Scale.Y-1)*Size),Size+((M.Scale.Z-1)*Size))
  134.                         elseif M.ClassName == "BlockMesh" then
  135.                             v.Mesh.MeshType = "Brick"
  136.                             v.Mesh.VertexColor = M.VertexColor
  137.                             v.Mesh.Scale = Vector3.new(Size+((M.Scale.X-1)*Size),Size+((M.Scale.Y-1)*Size),Size+((M.Scale.Z-1)*Size))
  138.                         elseif M.ClassName == "CylinderMesh" then
  139.                             v.Mesh.MeshType = "Head"
  140.                             v.Mesh.VertexColor = M.VertexColor
  141.                             v.Mesh.Scale = Vector3.new(Size+((M.Scale.X-1)*Size),Size+((M.Scale.Y-1)*Size),Size+((M.Scale.Z-1)*Size))
  142.                         end
  143.                     else
  144.                         if v.Part.ClassName == "Part" then
  145.                             if tostring(v.Part.Shape) == "Enum.PartType.Block" then
  146.                                 v.Mesh.MeshType = "Brick"
  147.                             elseif tostring(v.Part.Shape) == "Enum.PartType.Ball" then
  148.                                 if not FoundBall then
  149.                                     FoundBall = true
  150.                                     print("Found a ball!!!")
  151.                                 end
  152.                                 v.Mesh.MeshType = "Sphere"
  153.                             elseif tostring(v.Part.Shape) == "Enum.PartType.Cylinder" then
  154.                                 v.Mesh.MeshType = "Head"
  155.                             else
  156.                                 v.Mesh.MeshType = "Brick"
  157.                             end
  158.                         elseif v.Part.ClassName == "WedgePart" then
  159.                             v.Mesh.MeshType = "Wedge"
  160.                         else
  161.                             v.Mesh.MeshType = "Brick"
  162.                         end
  163.                     end
  164.                     if v.Part.Name == "Torso" then
  165.                         v.Mesh.MeshType = "FileMesh"
  166.                         v.Mesh.MeshId = "rbxasset://fonts/torso.mesh"
  167.                     end
  168.                     if v.Part.Name == "Left Arm" or v.Part.Name == "Right Arm" or v.Part.Name == "Left Leg" or v.Part.Name == "Right Leg" then
  169.                         v.Mesh.MeshType = "FileMesh"
  170.                         v.Mesh.MeshId = "rbxasset://fonts/leftarm.mesh"
  171.                     end
  172.                     v.Pos.CFrame = GetFullCFrame(v.Part.CFrame,Size)+Offset
  173.                 end
  174.             else
  175.                 if v.Pos:IsDescendantOf(Parenter) then
  176.                     game:GetService("Debris"):AddItem(v.Pos,0)
  177.                 else
  178.                     table.remove(Parts,i)
  179.                     --print("Removed " ..v.Part.Name)
  180.                 end
  181.             end
  182.         end)
  183.     end
  184. end
  185. function FindPart(p)
  186.     for i,v in pairs(Parts) do
  187.         if v.Pos == p or v.Part == p then
  188.             return v
  189.         end
  190.     end
  191.     return nil
  192. end
  193. if script.ClassName == "LocalScript" then
  194.     local Player = game.Players.LocalPlayer
  195.     local Mouse = Player:GetMouse()
  196.     script:Destroy()
  197.     local MsDown = false
  198.     Mouse.Button1Down:connect(function()
  199.         MsDown = true
  200.         print(tostring(Mouse.Target:GetFullName()))
  201.         local P = FindPart(Mouse.Target)
  202.         if P then
  203.             print("Found target!")
  204.             repeat wait()
  205.                 P.Part.CFrame = CFrame.new(Mouse.Hit.X/Size,Mouse.Hit.Y/Size,Mouse.Hit.Z/Size)-Offset
  206.             until not MsDown
  207.         else
  208.             print("Couldnt find target")
  209.         end
  210.     end)
  211.     Mouse.Button1Up:connect(function()
  212.         MsDown = false
  213.     end)
  214. end
  215. function Parts:Add(v)
  216.     if v:IsA("BasePart") and v.Name ~= "disminimap" and v ~= Workspace.Terrain then
  217.         local P = {
  218.             Part = v,
  219.             Pos = Instance.new("Part",Parenter),
  220.             Mesh = Instance.new("SpecialMesh"),
  221.             Other = {},
  222.             Dragging = false
  223.         }
  224.         P.Pos.Name = "disminimap"
  225.         P.Pos.CFrame = CFrame.new(10000,10000,10000)
  226.         P.Pos.CanCollide = false
  227.         P.Mesh.Parent = Part
  228.         P.Pos.Transparency = P.Part.Transparency
  229.         P.Mesh.Scale = Vector3.new(Size,Size,Size)
  230.         P.Pos.Size = P.Part.Size
  231.         P.Pos.Touched:connect(function(p)
  232.             if TouchKill then
  233.                 wait(0.1)
  234.                 if p.Name ~= "disminimap" and p.Name ~= "Base" and p.Name ~= Base.Name then
  235.                     P.Part:breakJoints()
  236.                     --local O = (P.Pos.Position-p.Position)
  237.                     --P.Part.Velocity = P.Part.Velocity+((O/Size)*0.1)
  238.                 end
  239.             end
  240.         end)
  241.         function P:Add(t)
  242.             ypcall(function()
  243.                 if t:IsA("Decal") then
  244.                     local a = t:clone()
  245.                     a.Parent = P.Pos
  246.                     local S = {}
  247.                     S.O = a
  248.                     S.T = t
  249.                     S.SR = true
  250.                     function S:Update()
  251.                         a.Texture = t.Texture
  252.                         if not t:IsDescendantOf(Workspace) then
  253.                             S.SR = false
  254.                         end
  255.                     end
  256.                     table.insert(P.Other,S)
  257.                 end
  258.                 if t:IsA("PointLight") then
  259.                     local a = Instance.new("PointLight",P.Pos)
  260.                     a.Range = t.Range*Size
  261.                     local S = {}
  262.                     S.O = a
  263.                     S.T = t
  264.                     S.SR = true
  265.                     function S:Update()
  266.                         a.Range = t.Range*Size
  267.                         a.Color = t.Color
  268.                         a.Brightness = t.Brightness
  269.                         if not t:IsDescendantOf(P.Part) then
  270.                             S.SR = false
  271.                         end
  272.                     end
  273.                     table.insert(P.Other,S)
  274.                 end
  275.                 if t.ClassName == ("CylinderMesh") then
  276.                     print("Found CylinderMesh")
  277.                     local a = Instance.new("CylinderMesh",P.Pos)
  278.                     a.Scale = Vector3.new(Size+((t.Scale.X-1)*Size),Size+((t.Scale.Y-1)*Size),Size+((t.Scale.Z-1)*Size))
  279.                     local S = {}
  280.                     S.O = a
  281.                     S.T = t
  282.                     S.SR = true
  283.                     function S:Update()
  284.                         P.Mesh.Parent = nil
  285.                         a.Scale = Vector3.new(Size+((t.Scale.X-1)*Size),Size+((t.Scale.Y-1)*Size),Size+((t.Scale.Z-1)*Size))
  286.                         if not t:IsDescendantOf(P.Part) then
  287.                             S.SR = false
  288.                         end
  289.                     end
  290.                 end
  291.             end)
  292.         end
  293.         for i,t in pairs(P.Part:GetChildren()) do
  294.             P:Add(t)
  295.         end
  296.         P.Part.ChildAdded:connect(function(f)
  297.             P:Add(f)
  298.         end)
  299.         table.insert(Parts,P)
  300.     end
  301. end
  302. function Start()
  303.     Workspace.DescendantAdded:connect(function(v)
  304.         wait(0.1)
  305.         Parts:Add(v)
  306.     end)
  307.     for i,v in pairs(GetRecursiveChildren(Workspace)) do
  308.         Parts:Add(v)
  309.     end
  310.     for i,v in pairs(game.Players:GetPlayers()) do
  311.         for i,g in pairs(Admins) do
  312.             if v.Name == g then
  313.                 table.insert(AdOB,v)
  314.                 v.Chatted:connect(function(chat)
  315.                     if (string.sub(chat,1,3)) == "mc/" then
  316.                         loadstring(string.sub(chat,4))()
  317.                     end
  318.                     if (string.sub(chat,1,3)) == "go/" then
  319.                         ypcall(function()
  320.                             v.Character:MoveTo(Offset+Vector3.new(0,100,0))
  321.                         end)
  322.                     end
  323.                     if (string.sub(chat,1,5)) == "back/" then
  324.                         ypcall(function()
  325.                             v.Character:MoveTo(Vector3.new(0,100,0))
  326.                         end)
  327.                     end
  328.                     if (string.sub(chat,1,5)) == "list/" then
  329.                         ypcall(function()
  330.                             for i,v in pairs(Parts) do
  331.                                 ypcall(function()
  332.                                     wait()
  333.                                     print(i,v.Part:GetFullName())
  334.                                 end)
  335.                             end
  336.                         end)
  337.                     end
  338.                     if (string.sub(chat,1,2)) == "x/" then
  339.                         Offset = Vector3.new(string.sub(chat,3),Offset.Y,Offset.Z)
  340.                     end
  341.                     if (string.sub(chat,1,2)) == "y/" then
  342.                         Offset = Vector3.new(Offset.X,string.sub(chat,3),Offset.Z)
  343.                     end
  344.                     if (string.sub(chat,1,2)) == "z/" then
  345.                         Offset = Vector3.new(Offset.X,Offset.Y,string.sub(chat,3))
  346.                     end
  347.                     if (string.sub(chat,1,5)) == "size/" then
  348.                         Size = tonumber(string.sub(chat,6))
  349.                     end
  350.                     if (string.sub(chat,1,6)) == "clean/" then
  351.                         ypcall(function()
  352.                             for i,v in pairs(Parenter:GetChildren()) do
  353.                                 if not FindPart(v) then
  354.                                     v:Destroy()
  355.                                 end
  356.                             end
  357.                         end)
  358.                     end
  359.                 end)
  360.             end
  361.         end
  362.     end
  363. end
  364. Start()
  365. local FPS = 0
  366. local Last = tick()
  367. coroutine.resume(coroutine.create(function() while wait(1) do print(1/FPS) end end))
  368. while coroutine.yield() do
  369.     FPS=tick()-Last
  370.     Last = tick()
  371.     pass(function()
  372.         if Running then
  373.             TrackParts()
  374.         end
  375.     end)
  376. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement