Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't this minimap for unions work?

Asked by
Mowblow 117
9 years ago

No errors that are shown in studio, however does not produce a minimap....

scale = 1 / 50

local representation = Instance.new("Model")
representation.Parent = game.Workspace
representation.Archivable = true
representation.Name = "Minimap"

function makeRepresentation(obj, cf, name)
    if not obj.Archivable then
        return 
    end
    if (obj.className == "UnionOperation") then
        local rep = Instance.new("Part")
        rep.Size = obj.Size * scale
        rep.Transparency = obj.Transparency
        rep.Reflectance = obj.Reflectance
        rep.BrickColor = obj.brickColor
        rep.Anchored = false
        rep.Locked = false
        rep.TopSurface = Enum.SurfaceType.Smooth
        rep.BottomSurface = Enum.SurfaceType.Smooth
        rep.Name = name
        local mesh = Instance.new("SpecialMesh")
        mesh.Scale = obj.Size * scale / rep.Size
        local objMesh = nil
        if objMesh ~= nil then
            mesh:Remove()
            mesh = objMesh:Clone()
            if (objMesh.className == "SpecialMesh") and (objMesh.MeshType == Enum.MeshType.FileMesh) then
                mesh.Scale = objMesh.Scale * scale
            else
                mesh.Scale = objMesh.Scale * obj.Size * scale / rep.Size
            end
        end
        mesh.Parent = rep
        rep.CFrame = cf:toWorldSpace(obj.CFrame + obj.Position * (scale - 1))
        rep.Parent = representation
    end
end

local _, t = wait()
print("Making a mini-map...")
makeRepresentation(game.Workspace, CFrame.new(0, 1.2, 0), "Workspace")
local _2, t2 = wait()
print("Mini-map is done! Time taken: " .. t2 - t .. " seconds.")

Answer this question