Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Create the main GUI
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "MinimapGUI"
- screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
- -- Create the minimap frame
- local minimapFrame = Instance.new("Frame")
- minimapFrame.Size = UDim2.new(0.25, 0, 0.25, 0) -- Adjust size as needed
- minimapFrame.Position = UDim2.new(0, 10, 1, -260) -- Position at the bottom left
- minimapFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- minimapFrame.BackgroundTransparency = 0.5
- minimapFrame.ClipsDescendants = true
- minimapFrame.Parent = screenGui
- -- Create the player dot
- local playerDot = Instance.new("Frame")
- playerDot.Size = UDim2.new(0, 10, 0, 10)
- playerDot.Position = UDim2.new(0.5, -5, 0.5, -5)
- playerDot.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- playerDot.BorderSizePixel = 0
- playerDot.Parent = minimapFrame
- -- Function to update the minimap
- local function updateMinimap()
- local player = game.Players.LocalPlayer
- if player and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
- local character = player.Character
- local rootPart = character.HumanoidRootPart
- local mapCenter = rootPart.Position
- local scaleFactor = 0.01 -- Adjust scaling factor as needed to get a more realistic distance
- -- Iterate over all players
- for _, otherPlayer in pairs(game.Players:GetPlayers()) do
- if otherPlayer ~= player and otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then
- local otherRootPart = otherPlayer.Character.HumanoidRootPart
- local relativePosition = (otherRootPart.Position - mapCenter) * scaleFactor
- -- Check if the relative position is within the minimap bounds
- if math.abs(relativePosition.X) <= 0.5 and math.abs(relativePosition.Z) <= 0.5 then
- local dot = minimapFrame:FindFirstChild(otherPlayer.Name)
- if not dot then
- dot = Instance.new("Frame")
- dot.Size = UDim2.new(0, 10, 0, 10)
- dot.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- dot.BorderSizePixel = 0
- dot.Name = otherPlayer.Name
- dot.Parent = minimapFrame
- end
- local posX = 0.5 + relativePosition.X
- local posY = 0.5 - relativePosition.Z
- dot.Position = UDim2.new(posX, -5, posY, -5)
- else
- -- Remove the dot if it's outside the minimap bounds
- local dot = minimapFrame:FindFirstChild(otherPlayer.Name)
- if dot then
- dot:Destroy()
- end
- end
- end
- end
- end
- end
- -- Update the minimap every frame
- game:GetService("RunService").RenderStepped:Connect(updateMinimap)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement