Advertisement
killerbrenden

Minimap

Jul 10th, 2020
1,103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. local o = script.Parent:WaitForChild("ViewportFrame")
  2.  
  3. local player = game.Players.LocalPlayer
  4. local character = player.Character or player.CharacterAdded:Wait()
  5.  
  6. local function createBox(char, color)
  7.     local box = Instance.new("Part")
  8.     box.Size = Vector3.new(4,1,4)
  9.     box.CFrame = char:WaitForChild("HumanoidRootPart").CFrame + Vector3.new(0,3,0)
  10.     box.Color = color
  11.     box.Anchored = true
  12.     box.CanCollide = false
  13.     box.Parent = o
  14.     box.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
  15.     box.BackSurface = Enum.SurfaceType.SmoothNoOutlines
  16.     box.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
  17.     box.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
  18.     box.RightSurface = Enum.SurfaceType.SmoothNoOutlines
  19.     box.TopSurface = Enum.SurfaceType.SmoothNoOutlines
  20. end
  21.  
  22. local function update()
  23.     pcall(function()
  24.         if character:WaitForChild("Humanoid").Health > 0 then
  25.             o:ClearAllChildren()
  26.            
  27.             local cam = Instance.new("Camera")
  28.             cam.Name = "ViewportCam"
  29.             cam.Parent = o
  30.             cam.CameraSubject = character:WaitForChild("Humanoid")
  31.             cam.FieldOfView = workspace.CurrentCamera.FieldOfView
  32.             cam.Focus = character:WaitForChild("Head").CFrame
  33.            
  34.             cam.CFrame = (character:WaitForChild("HumanoidRootPart").CFrame * CFrame.Angles(math.rad(-90),0,0)) + Vector3.new(0,20,0)
  35.             o.CurrentCamera = cam
  36.                
  37.             for _,newObj in pairs(workspace:GetChildren()) do
  38.                 if newObj:IsA("Model") then
  39.                     if newObj:FindFirstChild("Humanoid") and newObj.Name == player.Name then
  40.                         local clone = newObj:Clone()
  41.                         clone.Parent = o
  42.                         createBox(newObj, Color3.fromRGB(0,255,0))
  43.                     elseif newObj:FindFirstChild("Humanoid") and newObj.Name ~= player.Name then
  44.                         local clone = newObj:Clone()
  45.                         clone.Parent = o
  46.                         createBox(newObj, Color3.fromRGB(255,0,0))
  47.                     else
  48.                         local clone = newObj:Clone()
  49.                         clone.Parent = o
  50.                     end
  51.                 elseif newObj:IsA("BasePart") then
  52.                     local clone = newObj:Clone()
  53.                     clone.Parent = o
  54.                 end
  55.             end
  56.         end
  57.     end)
  58. end
  59.  
  60. game:GetService("RunService").RenderStepped:Connect(function()
  61.     update()
  62. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement