Advertisement
InTesting

Sweater V2

Jul 24th, 2019
581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.45 KB | None | 0 0
  1. print'https://pastebin.com/1b6diG9Q'
  2. local function Get_Union(Primary_Part,table_of_obj,is_negated)
  3.     --[[
  4.         // Description \\
  5.         Modified Function of BasePart:UnionAsync and BasePart:SubtractAsync. All wrapped
  6.         in one neat Function. It even gets rid of the parts in the first and second
  7.         parameters.
  8.        
  9.         -- Input --
  10.          --> Mandatory
  11.          1. (Instance) First parameter is the part being used.
  12.          2. (Table) Second parameter is the table value.
  13.        
  14.          --> Optional
  15.          3. (Boolean, nil) Third parameter is whether if its being negated or not. If true, it will negate.
  16.        
  17.         -- Output --
  18.          1. Union instance
  19.        
  20.     --]]
  21.     local parts = {Primary_Part}
  22.     Primary_Part.Parent = workspace
  23.     for _,v in pairs(table_of_obj)do
  24.         table.insert(parts,v)
  25.     end
  26.     local union
  27.     if not is_negated then
  28.         union = Primary_Part:UnionAsync(table_of_obj)
  29.     else
  30.         union = Primary_Part:SubtractAsync(table_of_obj)
  31.     end
  32.     for _,v in pairs(parts)do
  33.         v:Destroy()
  34.     end
  35.     union.Parent = workspace
  36.    
  37.     return union
  38. end
  39. local function Weld_ify(part_1,part_2)
  40.     --[[
  41.         // Description \\
  42.         Shortens welding. Returns weld. The WeldConstraint will be parented under
  43.         part_1 from parameter 1.
  44.        
  45.         -- Input --
  46.          --> Mandatory
  47.          1. (Instance) First parameter will be the part that will be parenting the
  48.             WeldConstraint/s.
  49.          2. (Instance) Second parameter will be the part that will be welded to the
  50.             part from parameter 1.
  51.            
  52.             --> or
  53.             (table) Second parameter can also be a table value of parts.
  54.            
  55.         -- Output --
  56.          1. If parameter 2 was an:
  57.              + Instance, Then it will return:
  58.                 (Instance) The WeldConstraint used In the Function.
  59.              + Table, Then it will return:
  60.                 (table) The WeldConstraints used In the Function.
  61.     --]]
  62.     if typeof(part_2)=='Instance'then
  63.         local weldc = Instance.new("WeldConstraint",part_1)
  64.         weldc.Part0 = part_1
  65.         weldc.Part1 = part_2
  66.         return weldc
  67.     elseif typeof(part_2)=='table'then
  68.         local weldc_list = {}
  69.         for _,v in pairs(part_2)do
  70.             local weldc = Instance.new("WeldConstraint",part_1)
  71.             weldc.Part0 = part_1
  72.             weldc.Part1 = v
  73.             table.insert(weldc_list,weldc)
  74.         end
  75.         return weldc_list
  76.     else
  77.         error('Function failed: Argument 2 is not an Instance or a table.')
  78.     end
  79. end
  80.  
  81. local function Bevel_ify(para_1,depth)
  82.     --[[
  83.         // Description \\
  84.         Function returns the instance of the anchored beveled part.
  85.        
  86.          1. First parameter is the part of what it is beveling.
  87.             Putting iN a table of properties will also work.
  88.        
  89.          2. Second parameter is how deep it is (number).
  90.        
  91.         This Function needs:
  92.             - GetUnion()
  93.            
  94.         Warning: This is a yielding Function. Script will pause While Function is active.
  95.     --]]
  96.     local part_1
  97.     local mr = math.rad
  98.     if typeof(para_1)=='Instance'then
  99.         part_1 = para_1
  100.     elseif typeof(para_1)=='table'then
  101.         part_1 = Instance.new('Part',workspace)
  102.         for i,v in pairs(para_1)do
  103.             pcall(function()
  104.                 part_1[i] = v
  105.             end)
  106.         end
  107.     end
  108.     part_1.Anchored = true
  109.    
  110.     local function Get_Corner(Positive_x,Positive_y,Positive_z)
  111.         local X_CF = part_1.Size.X * .5
  112.         local Y_CF = part_1.Size.Y * .5
  113.         local Z_CF = part_1.Size.Z * .5
  114.        
  115.         local CF_Ang,mid_CA_num
  116.        
  117.         if not Positive_x or Positive_x==0 then
  118.             X_CF = -X_CF
  119.         end
  120.         if not Positive_y or Positive_y==0 then
  121.             Y_CF = -Y_CF
  122.         end
  123.         if not Positive_z or Positive_z==0 then
  124.             Z_CF = -Z_CF
  125.         end
  126.        
  127.         if Positive_x==Positive_y then
  128.             if Positive_z==Positive_x then
  129.                 mid_CA_num = -45
  130.             else
  131.                 mid_CA_num = 45
  132.             end
  133.         elseif Positive_z==Positive_x then
  134.             mid_CA_num = 135
  135.         else
  136.             mid_CA_num = -135
  137.         end
  138.        
  139.         CF_Ang = CFrame.Angles(0,mr(mid_CA_num),mr(45))
  140.        
  141.         local part = Instance.new("Part",workspace)
  142.         part.Anchored = true
  143.         part.Size = Vector3.new(depth * 2,part_1.Size.Y,part_1.Size.Y)
  144.         part.CFrame = part_1.CFrame *
  145.             CFrame.new(X_CF,Y_CF,Z_CF) *
  146.             CF_Ang
  147.         part.Name = Positive_x.. Positive_y .. Positive_z
  148.        
  149.         return part
  150.     end
  151.     local function Get_Edge(wrap_axis,Isnegative_1,Isnegative_2)
  152.         local ps = part_1.Size
  153.         local prime_1 = 1
  154.         local prime_2 = 1
  155.         if Isnegative_1==1 then
  156.             prime_1 = -1
  157.         end
  158.         if Isnegative_2==1 then
  159.             prime_2 = -1
  160.         end
  161.        
  162.         local part = Instance.new("Part",workspace)
  163.         part.Anchored = true
  164.         if wrap_axis==0 or not wrap_axis then
  165.             part.Size = Vector3.new(part_1.Size.X,depth * 2,depth * 2)
  166.             part.CFrame = part_1.CFrame *
  167.                 CFrame.new(0,ps.Y * .5 * prime_1,ps.Z * .5 * prime_2) *
  168.                 CFrame.Angles(mr(45),0,0)
  169.                
  170.         elseif wrap_axis==1 then
  171.             part.Size = Vector3.new(depth * 2,part_1.Size.Y,depth * 2)
  172.             part.CFrame = part_1.CFrame *
  173.                 CFrame.new(ps.X * .5 * prime_1,0,ps.Z * .5 * prime_2) *
  174.                 CFrame.Angles(0,mr(45),0)
  175.         elseif wrap_axis==2 or not wrap_axis then
  176.             part.Size = Vector3.new(depth * 2,depth * 2,part_1.Size.Z)
  177.             part.CFrame = part_1.CFrame *
  178.                 CFrame.new(ps.X * .5 * prime_1,ps.Y * .5 * prime_2,0) *
  179.                 CFrame.Angles(0,0,mr(45))
  180.         end
  181.        
  182.         return part
  183.     end
  184.    
  185.     local bev = {
  186.     Get_Corner(0,0,0),
  187.     Get_Corner(0,0,1),
  188.     Get_Corner(0,1,0),
  189.     Get_Corner(0,1,1),
  190.     Get_Corner(1,0,0),
  191.     Get_Corner(1,0,1),
  192.     Get_Corner(1,1,0),
  193.     Get_Corner(1,1,1),
  194.    
  195.     Get_Edge(0,0,0),
  196.     Get_Edge(0,0,1),
  197.     Get_Edge(0,1,0),
  198.     Get_Edge(0,1,1),
  199.    
  200.     Get_Edge(1,0,0),
  201.     Get_Edge(1,0,1),
  202.     Get_Edge(1,1,0),
  203.     Get_Edge(1,1,1),
  204.    
  205.     Get_Edge(2,0,0),
  206.     Get_Edge(2,0,1),
  207.     Get_Edge(2,1,0),
  208.     Get_Edge(2,1,1)
  209.     }
  210.    
  211.     local union = Get_Union(part_1,bev,true)
  212.    
  213.     return union
  214. end
  215. local function Girl_Torso(part)
  216.     --[[
  217.         // Description \\
  218.         Returns Girl Torso made out of unions and negateoperations.
  219.        
  220.         -- Output --
  221.          1. (Instance) Girl Torso Union.
  222.        
  223.         This Function needs:
  224.           - Bevel_ify Function
  225.           - Get_Union Function
  226.        
  227.         This is a yielding Function.
  228.     --]]
  229.    
  230.     local Bevel_1 = part
  231.     Bevel_1.Size = Vector3.new(2.02,2.02,1.02)
  232.    
  233.     local Bevil_ified_1 = Bevel_ify(Bevel_1,.02)
  234.    
  235.     local function mpart(ori,pos,size)
  236.         local p = Instance.new("Part")
  237.         p.Anchored = true
  238.         p.Orientation = ori
  239.         p.Position = pos
  240.         p.Size = size
  241.        
  242.         return p
  243.     end
  244.    
  245.     Bevil_ified_1.Anchored = true
  246.     Bevil_ified_1.Position = Vector3.new(-26, -11.5, -8.5)
  247.    
  248.     local girl_torso = Get_Union(Bevil_ified_1,{
  249.         mpart(Vector3.new(0, -180, -24.17),
  250.             Vector3.new(-27.415, -11.41, -8.5),
  251.             Vector3.new(1, 1.21, 2.62)
  252.         ),
  253.         mpart(Vector3.new(0, 0, 21.92),
  254.             Vector3.new(-24.6, -12, -8.5),
  255.             Vector3.new(1, 1, 3)
  256.         ),
  257.         mpart(Vector3.new(0, 0, -24.17),
  258.             Vector3.new(-24.542, -11.371, -8.5),
  259.             Vector3.new(1, 1.21, 2.62)
  260.         ),
  261.         mpart(Vector3.new(16.39, 0, 0),
  262.             Vector3.new(-26, -11.4, -7.53),
  263.             Vector3.new(2.9, 1, 1)
  264.         ),
  265.         mpart(Vector3.new(0, -180, 22.53),
  266.             Vector3.new(-27.375, -12.03, -8.5),
  267.             Vector3.new(1, 1, 3)
  268.         ),
  269.         mpart(Vector3.new(13.65, 0, 0),
  270.             Vector3.new(-26, -12.111, -9.491),
  271.             Vector3.new(2.9, 1.08, 1)
  272.         ),
  273.         mpart(Vector3.new(-15.45, 0, 0),
  274.             Vector3.new(-26, -12.09, -7.53),
  275.             Vector3.new(2.9, 1, 1)
  276.         ),
  277.         mpart(Vector3.new(-13.77, 0, 0),
  278.                             Vector3.new(-26, -11.336, -9.48),
  279.                             Vector3.new(2.9, 1, 1)
  280.                         )
  281.                        
  282.     },true)
  283.    
  284.     return girl_torso
  285. end
  286. local function Sweater_Version_2(Character_1,color3_value_1)
  287.     --[[
  288.         // Description \\
  289.         Makes a new sweater from given character. Returns Sweater Model.
  290.        
  291.         -- Input --
  292.          --> Mandatory
  293.          1. (Instance) It can be a Player's character or a some rig. But it
  294.             must have:
  295.              -- A torso.
  296.          --> Optional
  297.          2. (Color3) Color3 value for sweater.
  298.            
  299.         -- Output --
  300.          1. (Instance) Sweater Model.
  301.        
  302.         This Function needs:
  303.           - Get_Union()
  304.           - Bevel_ify()
  305.           - Weld_ify()
  306.        
  307.         This Function also might want:
  308.           - Girl_Torso()
  309.                 If the character from parameter 1 has a Girl Torso character
  310.                 mesh.
  311.                
  312.         Warning: This Function can yield.
  313.     --]]
  314.     local l_arm = Character_1:FindFirstChild'Left Arm'
  315.     local r_arm = Character_1:FindFirstChild'Right Arm'
  316.     local torso = Character_1:FindFirstChild'Torso'
  317.     local sl_arm,sr_arm,s_torso
  318.     if not torso then
  319.         error('Function failed: No torso in character in paramter 1.')
  320.     end
  321.     if color3_value_1==nil then
  322.         color3_value_1 = Color3.fromRGB(0,0,255)
  323.     elseif typeof(color3_value_1)~='Color3'then
  324.         color3_value_1 = Color3.fromRGB(0,0,255)
  325.     end
  326.     if l_arm then
  327.         local part = Instance.new("Part")
  328.         part.Size = Vector3.new(1.02,2.02,1.02)
  329.         part.Color = color3_value_1
  330.         part.Material = Enum.Material.Fabric
  331.        
  332.         local bevel_1 = Bevel_ify(part,.02)
  333.         local part_1 = Instance.new("Part")
  334.         part_1.CFrame = bevel_1.CFrame *
  335.             CFrame.new(0,bevel_1.Size.Y * -.5,0)
  336.         part_1.Size = Vector3.new(1.25,.2,1.25)
  337.        
  338.         local union_1 = Get_Union(bevel_1,{part_1},true)
  339.         sl_arm = union_1
  340.     end
  341.     if r_arm then
  342.         local part = Instance.new("Part")
  343.         part.Size = Vector3.new(1.02,2.02,1.02)
  344.         part.Color = color3_value_1
  345.         part.Material = Enum.Material.Fabric
  346.        
  347.         local bevel_1 = Bevel_ify(part,.02)
  348.         local part_1 = Instance.new("Part")
  349.         part_1.CFrame = bevel_1.CFrame *
  350.             CFrame.new(0,bevel_1.Size.Y * -.5,0)
  351.         part_1.Size = Vector3.new(1.25,.2,1.25)
  352.        
  353.         local union_1 = Get_Union(bevel_1,{part_1},true)
  354.         sr_arm = union_1
  355.     end
  356.     if torso then
  357.         local Has_Girl_Torso = false
  358.         for _,v in pairs(Character_1:GetChildren())do
  359.             if v:IsA'CharacterMesh'then
  360.                 if v.MeshId==48112070 then
  361.                     Has_Girl_Torso = true
  362.                     break
  363.                 end
  364.             end
  365.         end
  366.         if Has_Girl_Torso then
  367.             local part = Instance.new("Part")
  368.             part.Color = color3_value_1
  369.            
  370.             local girl_torso = Girl_Torso(part)
  371.             girl_torso.Material = Enum.Material.Fabric
  372.             s_torso = girl_torso
  373.         else
  374.             local part = Instance.new("Part")
  375.             part.Size = Vector3.new(2.02,2.02,1.02)
  376.             part.Color = color3_value_1
  377.             part.Material = Enum.Material.Fabric
  378.            
  379.             local bevel_1 = Bevel_ify(part,.02)
  380.             s_torso = bevel_1
  381.         end
  382.     end
  383.    
  384.     local mod = Instance.new("Model",Character_1)
  385.    
  386.     if sl_arm then
  387.         sl_arm.Parent = mod
  388.         sl_arm.CFrame = l_arm.CFrame *
  389.             CFrame.new(0,.1,0)
  390.         Weld_ify(l_arm,sl_arm)
  391.     end
  392.     if sr_arm then
  393.         sr_arm.Parent = mod
  394.         sr_arm.CFrame = r_arm.CFrame *
  395.             CFrame.new(0,.1,0)
  396.         Weld_ify(r_arm,sr_arm)
  397.     end
  398.     if s_torso then
  399.         s_torso.Parent = mod
  400.         s_torso.Color = color3_value_1
  401.         s_torso.CFrame = torso.CFrame
  402.         Weld_ify(torso,s_torso)
  403.     end
  404.    
  405.     for _,v in pairs(mod:GetChildren())do
  406.         v.Anchored = false
  407.         v.Massless = true
  408.         v.CanCollide = false
  409.     end
  410.    
  411.     return mod
  412. end
  413.  
  414. Sweater_Version_2(owner.Character)
  415. owner.CharacterAdded:Connect(function(ch)
  416.     Sweater_Version_2(owner.Character)
  417. end)
  418. print'Repost my sweater = youre fat'
  419. print'but you can change the color tho but nothing else.'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement