Advertisement
HowToRoblox

MinimapHandler

Aug 13th, 2021
3,647
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.73 KB | None | 1 0
  1. local screenGui = script.Parent
  2. local frame = script.Parent:WaitForChild("MinimapFrame")
  3. local arrow = frame:WaitForChild("DirectionArrow")
  4.  
  5.  
  6. local plr = game.Players.LocalPlayer
  7.  
  8. local char = plr.Character or plr.CharacterAdded:Wait()
  9.  
  10. local hrp = char:WaitForChild("HumanoidRootPart")
  11. local humanoid = char:WaitForChild("Humanoid")
  12.  
  13.  
  14. local uis = game:GetService("UserInputService")
  15.  
  16.  
  17. local vpf = Instance.new("ViewportFrame", frame)
  18. vpf.Size = UDim2.new(1, 0, 1, 0)
  19. vpf.BackgroundTransparency = 1
  20.  
  21.  
  22. local currentCamera = Instance.new("Camera")
  23.  
  24. currentCamera.FieldOfView = 1
  25. currentCamera.CameraType = Enum.CameraType.Scriptable
  26.  
  27. currentCamera.Parent = workspace
  28.  
  29.  
  30. vpf.CurrentCamera = currentCamera
  31.  
  32.  
  33. local parts = script:WaitForChild("MinimapParts")
  34. parts.Parent = workspace
  35.  
  36. local partsCF = CFrame.Angles(math.rad(90), 0, 0) * CFrame.new(-15, -10, 3)
  37.  
  38.  
  39. for i, minimapObject in pairs(workspace.Map:GetDescendants()) do
  40.  
  41.     if minimapObject:IsA("BasePart") then
  42.        
  43.         minimapObject:Clone().Parent = vpf
  44.     end
  45. end
  46.  
  47.  
  48. game:GetService("RunService").RenderStepped:Connect(function()
  49.    
  50.     local camCFrame = CFrame.new(hrp.Position + Vector3.new(0, 5000, 0), hrp.Position)
  51.    
  52.     currentCamera.CFrame = camCFrame
  53.    
  54.    
  55.     parts:SetPrimaryPartCFrame(workspace.CurrentCamera.CFrame * partsCF)
  56.    
  57.    
  58.     vpf.Rotation = hrp.Orientation.Y + 90
  59. end)
  60.  
  61.  
  62.  
  63. uis.InputBegan:Connect(function(inp, processed)
  64.    
  65.    
  66.     if not processed and inp.KeyCode == Enum.KeyCode.M then    
  67.        
  68.         if partsCF == CFrame.Angles(math.rad(90), 0, 0) * CFrame.new(-15, -10, 3) then
  69.            
  70.             partsCF = CFrame.Angles(math.rad(90), 0, 0) * CFrame.new(0, -6, 0)
  71.            
  72.         else
  73.             partsCF = CFrame.Angles(math.rad(90), 0, 0) * CFrame.new(-15, -10, 3)
  74.         end
  75.     end
  76. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement