Minimap Rendering

This is some code for a minimap. Every time i use it though it loads a section but everything else doesn’t load. Is there any way to make this keep rendering every few seconds?

Update: I did some tests and i think it has to do with whats on the map, and whats not on the map. How can i make it now so that it gets all the children of the folder and not not just the direct ones

I wonder if the part that clones the map into the minimap is running too early, so that it misses things that haven’t loaded yet?

That could of been the solution, but i think it doesn’t clone the object it just sets up a camera and displays what the camera sees.

image
It does.

If your game uses Instance Streaming (the StreamingEnabled property underneath Workspace enables that), the “only one section of the map present, everything else missing” problem is probably because of that. Roblox will stream in 3D objects near your character, and objects outside that range are not gonna be present.

To fix this, I’d suggest connecting to the MapObjects.ChildAdded and MapObjects.ChildRemoved events, so that the minimap always reflects the state of the MapObjects object.

Here’s how that would look:

local PresentObjects = {}

for _, Object in pairs(MapObjects:GetChildren()) do
    local ClonedObject = Object:Clone()
    ClonedObject.Parent = Minimap
    PresentObjects[Object] = ClonedObject
end

Minimap.ChildAdded:Connect(function(Object)
    local ClonedObject = Object:Clone()
    ClonedObject.Parent = Minimap
    PresentObjects[Object] = ClonedObject
end)

Minimap.ChildRemoved:Connect(function(Object)
    local ClonedObject = PresentObjects[Object]
    if ClonedObject then
        ClonedObject:Destroy()
    end
end)

The PresentObjects table is required to keep track of which objects have been cloned, and a reference to the object clone itself to destroy it when the object in workspace streams out.