Advertisement
AnonymousJG179

Mini Map

Jul 8th, 2024
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. -- Create the main GUI
  2. local screenGui = Instance.new("ScreenGui")
  3. screenGui.Name = "MinimapGUI"
  4. screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  5.  
  6. -- Create the minimap frame
  7. local minimapFrame = Instance.new("Frame")
  8. minimapFrame.Size = UDim2.new(0.25, 0, 0.25, 0) -- Adjust size as needed
  9. minimapFrame.Position = UDim2.new(0, 10, 1, -260) -- Position at the bottom left
  10. minimapFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  11. minimapFrame.BackgroundTransparency = 0.5
  12. minimapFrame.ClipsDescendants = true
  13. minimapFrame.Parent = screenGui
  14.  
  15. -- Create the player dot
  16. local playerDot = Instance.new("Frame")
  17. playerDot.Size = UDim2.new(0, 10, 0, 10)
  18. playerDot.Position = UDim2.new(0.5, -5, 0.5, -5)
  19. playerDot.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  20. playerDot.BorderSizePixel = 0
  21. playerDot.Parent = minimapFrame
  22.  
  23. -- Function to update the minimap
  24. local function updateMinimap()
  25. local player = game.Players.LocalPlayer
  26. if player and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
  27. local character = player.Character
  28. local rootPart = character.HumanoidRootPart
  29. local mapCenter = rootPart.Position
  30. local scaleFactor = 0.01 -- Adjust scaling factor as needed to get a more realistic distance
  31.  
  32. -- Iterate over all players
  33. for _, otherPlayer in pairs(game.Players:GetPlayers()) do
  34. if otherPlayer ~= player and otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
  35. local otherRootPart = otherPlayer.Character.HumanoidRootPart
  36. local relativePosition = (otherRootPart.Position - mapCenter) * scaleFactor
  37.  
  38. -- Check if the relative position is within the minimap bounds
  39. if math.abs(relativePosition.X) <= 0.5 and math.abs(relativePosition.Z) <= 0.5 then
  40. local dot = minimapFrame:FindFirstChild(otherPlayer.Name)
  41. if not dot then
  42. dot = Instance.new("Frame")
  43. dot.Size = UDim2.new(0, 10, 0, 10)
  44. dot.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  45. dot.BorderSizePixel = 0
  46. dot.Name = otherPlayer.Name
  47. dot.Parent = minimapFrame
  48. end
  49. local posX = 0.5 + relativePosition.X
  50. local posY = 0.5 - relativePosition.Z
  51. dot.Position = UDim2.new(posX, -5, posY, -5)
  52. else
  53. -- Remove the dot if it's outside the minimap bounds
  54. local dot = minimapFrame:FindFirstChild(otherPlayer.Name)
  55. if dot then
  56. dot:Destroy()
  57. end
  58. end
  59. end
  60. end
  61. end
  62. end
  63.  
  64. -- Update the minimap every frame
  65. game:GetService("RunService").RenderStepped:Connect(updateMinimap)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement