Watch the video for what I’m saying to make sense
As you can see, if you get far away from the part which has the text label on it the text label goes into a completely wrong position, if you are close however it works. I have no idea why it does this
local Minimap = script.Parent:WaitForChild("Minimap")
local Arrow = Minimap:WaitForChild("Arrow")
local IconsFolder = game.Workspace:WaitForChild("Icons")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Camera = Instance.new("Camera")
Camera.FieldOfView = 1
Camera.CameraType = Enum.CameraType.Scriptable
Camera.Parent = game.Workspace
Minimap.CurrentCamera = Camera
task.wait(2)
local function isPartFromCharacter(part)
return part:IsDescendantOf(Character)
end
for i, Object in pairs(game.Workspace:GetDescendants()) do
if isPartFromCharacter(Object) then
continue
end
if Object:IsA("Terrain") or not Object:IsA("BasePart") then
continue
end
Object:Clone().Parent = Minimap
end
for i, child in pairs(IconsFolder:GetChildren()) do
local ViewportSize = Camera.ViewportSize
local W2VP = Camera:WorldToViewportPoint(child.Position)
local normalizedX = W2VP.X / ViewportSize.X
local normalizedY = W2VP.Y / ViewportSize.Y
local iconGui = game.Players.LocalPlayer.PlayerGui.MinimapGui.Minimap:FindFirstChild(child.Name.."GUI")
if iconGui then
iconGui.Position = UDim2.new(normalizedX, 0, normalizedY, 0)
else
local TextClone = script.Parent.Parent.TextLabel:Clone()
TextClone.Text = child.Name
TextClone.Name = child.Name.."GUI"
TextClone.Position = UDim2.new(normalizedX, 0, normalizedY, 0)
TextClone.Parent = game.Players.LocalPlayer.PlayerGui.MinimapGui.Minimap
TextClone.BackgroundTransparency = 1
end
end
function add()
local ViewportSize = Camera.ViewportSize
for i, child in pairs(IconsFolder:GetChildren()) do
local W2VP = Camera:WorldToViewportPoint(child.Position)
local normalizedX = W2VP.X / ViewportSize.X
local normalizedY = W2VP.Y / ViewportSize.Y
local iconGui = game.Players.LocalPlayer.PlayerGui.MinimapGui.Minimap:FindFirstChild(child.Name.."GUI")
if iconGui then
print("found")
iconGui.Position = UDim2.new(normalizedX, 0, normalizedY, 0)
else
print("Not found")
end
end
end
function update()
local camCFrame = CFrame.new(HumanoidRootPart.Position + Vector3.new(0, 10000, 0), HumanoidRootPart.Position)
Camera.CFrame = camCFrame
Arrow.Rotation = -HumanoidRootPart.Orientation.Y - 90
add()
end
game["Run Service"]:BindToRenderStep("update", 1, update)