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

This Union Mini Map Script Won't Work properly?

Asked by 9 years ago

So, I got the script to make maps small with unions, but it doesn't minimap it correctly with the unions. For example, I made a gun out of unions I placed together, and after minimaping it with my script it came out all over the place. Any help in how to fix it? Thanks.

scale = 1 / 2

local representation = Instance.new("Model")
representation.Parent = game.Workspace
representation.archivable = true
representation.Name = "Model"
local unions = {}

function DefineForUnion() -- 
local things = game.Workspace:GetChildren()
    print("Found things...")
    for i , v in pairs (things) do
        if v.className == "UnionOperation" then
            table.insert(unions,v)
            print("Inserted unions to table...")
        end
    end
end
DefineForUnion()



function makeRepresentation(obj, cf, name)

    if not obj.archivable then
        return 
    end
    for i, union in pairs (unions) do 
        print("Found the unions...")
        if (union.className == "UnionOperation") then
            local new = union:Clone()           
            new.Size = union.Size * scale
            new.Parent = game.Workspace
            new.CFrame = CFrame.new(0,10,0)
        end
    end 
    if ((obj.className == "Part") or (obj.className == "Seat") or (obj.className == "SpawnLocation") or (obj.className == "WedgePart") or (obj.className == "TrussPart") or (obj.className == "VehicleSeat")) 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 = true
        rep.Locked = false
        rep.TopSurface = Enum.SurfaceType.Smooth
        rep.BottomSurface = Enum.SurfaceType.Smooth

        rep.Name = obj.Name
        local mesh = Instance.new("SpecialMesh")
        mesh.Scale = obj.Size * scale / rep.Size
        local list = obj:GetChildren()
        local objMesh = nil
        for x = 1, #list do
            if (list[x].className == "Decal") then
                local copy = list[x]:Clone()
                copy.Parent = rep
            elseif (list[x].className == "SpecialMesh") or (list[x].className == "CylinderMesh") or (list[x].className == "BlockMesh") then
                objMesh = list[x]
            end
        end
        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
                mesh.Offset = objMesh.Offset * scale
            else
                mesh.Scale = objMesh.Scale * obj.Size * scale / rep.Size
                mesh.Offset = objMesh.Offset * scale
            end
        elseif obj.className ~= "UnionOperation" and obj.Shape == Enum.PartType.Ball then
            mesh.MeshType = Enum.MeshType.Sphere
        elseif obj.className ~= "UnionOperation" and obj.Shape == Enum.PartType.Block then
            mesh:Remove()
            mesh = Instance.new("BlockMesh")
            mesh.Scale = obj.Size * scale / rep.Size
            --mesh.MeshType = Enum.MeshType.Brick
        else
            if obj.className ~= "UnionOperation" then
                print("This is a union, no mesh here!")
            else 
                mesh.MeshType = Enum.MeshType.Cylinder
                rep.Shape = Enum.PartType.Ball  
            end
        end
        mesh.Parent = rep
        rep.CFrame = cf:toWorldSpace(obj.CFrame + obj.Position * (scale - 1))
        rep.Parent = representation
    else
        if (obj == workspace) or (((obj.className == "Model") or (obj.className == "Tool") or (obj.className == "Hat")) and (obj ~= representation)) then
            local list = obj:GetChildren()
            for x = 1, #list do
                wait()
                makeRepresentation(list[x], cf, name .. "->" .. list[x].Name)
            end
        end
    end
end

local _, t = wait()
print("Reducing...")
makeRepresentation(workspace, CFrame.new(0, 1.2, 0), "Workspace")
local _2, t2 = wait()
print("Done! Time taken: " .. t2 - t .. " seconds.")
0
Are the 'BasePart''s Anchored? TheeDeathCaster 2368 — 9y
0
Yeah! alan3401 28 — 9y
0
I realize this is not an answer to fix your script, although try using this plugin. You don't have to, it's a suggestion. http://www.roblox.com/Model-Resize-Plugin-2-1-DRAG-TO-RESIZE-item?id=143613186 alphawolvess 1784 — 9y
0
AlphaWolvess you should answer this question, because it helped me and I will accept the answer! Thanks! alan3401 28 — 9y

Answer this question