Hi, so recently I was making an RTS game, and I needed a map.
I made some code about it, and it works perfectly fine;
local whitelistedClasses = {
"MeshPart",
"Part",
"UnionOperation",
"Model"
}
local viewport = script.Parent
local camera = Instance.new("Camera")
camera.Parent = viewport
viewport.CurrentCamera = camera
camera.FieldOfView = 10
camera.CFrame = CFrame.new(Vector3.new(0,10000,0), Vector3.new(0,0,0)) * CFrame.Angles(0,0,math.rad(90))
local dots = viewport.Parent.Parent:WaitForChild("Dots")
local player = game.Players.LocalPlayer
local character = player.Character
local root = character:WaitForChild("HumanoidRootPart")
local runService = game:GetService("RunService")
local function v3tov2(vector3)
local v2 = (viewport.AbsolutePosition + Vector2.new(100, 100)) + Vector2.new(vector3.X, vector3.Z)
return v2
end
local function updateMap()
for _,v in pairs(viewport:GetChildren()) do
if not v:IsA("LocalScript") then
v:Destroy()
end
end
for _,v in pairs(dots:GetChildren()) do
v:Destroy()
end
for _,v in pairs(workspace:GetChildren()) do
if v:IsA("Model") or v:IsA("MeshPart") or v:IsA("Part") or v:IsA("UnionOperation") then
if not v:FindFirstChild("Humanoid") then
local clone = v:Clone()
clone.Parent = viewport
else
local newV2 = v3tov2(v.PrimaryPart.Position)
local point = Instance.new("Frame")
point.Parent = dots
point.Position = UDim2.new(0, newV2.X, 0, newV2.Y)
point.Size = UDim2.new(0,5,0,5)
end
end
end
end
while wait(0.5) do
updateMap()
end
The only issue is, is that the viewport won’t encompass the ENTIRE map. I don’t know any kind of funny equation to do that kinda stuff, so please give me a hand
Please and thank you