Advertisement
InTesting

Better Functions

Dec 11th, 2019
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.13 KB | None | 0 0
  1. local function Instance2(c,p,Early_Parent)if not c then return;end;p=p or{};
  2. local a=Instance.new(c,(Early_Parent and p.Parent)or nil);for b,d in pairs(p)do local _,e=pcall(function()
  3. a[b]=d;end);if e then print(e);end;end;return a;end;
  4.  
  5. local function Rainbow(Instance_1,Property,Color_Increment,Wait_Increment)if not Instance_1 or not Property then return;end;
  6. Color_Increment=Color_Increment or 2;Wait_Increment=Wait_Increment or 1/60;coroutine.wrap(function()local frame=0;
  7. while true do frame=frame+Color_Increment;if frame>=360 then frame=0;end;Instance_1[Property]=Color3.fromHSV(frame/360,1,1);
  8. wait(Wait_Increment);end;end)();end;
  9.  
  10. local function Link_Properties(Instance_1,Property_1,Instance_2,Property_2)
  11. if not(Instance_1 and Instance_2 and Property_1 and Property_2)then return;end;
  12. return Instance_1.Changed:Connect(function(a)if not a then return;end;
  13. if a~=Property_1 then return;end;Instance_2[Property_2]=Instance_1[Property_1];end);end;
  14.  
  15. local function Get_Vertices_Based_On_Numbers(Center,Points,Distance)local CFrame=loadstring('return CFrame;')();
  16. local Vector3=loadstring('return Vector3;')();local Instance=loadstring('return Instance;')();
  17. if not(CFrame and Vector3 and Instance)then return;end;local Instance_2=loadstring('return Instance_2;')()or{};
  18. Instance_2.new=Instance_2.new or function(c,p)if not c then return;end;p=p or{};
  19. local a=Instance.new(c,p.Parent);for b,d in pairs(p)do local _,e=pcall(function()a[b]=d;end);if e then print(e);
  20. end;end;return a;end;local v3_val_1=Vector3.new(1,1,1);
  21. Center=(typeof(Center)=='Vector3'and Center)or Vector3.new(0,0,0);
  22. Points=(type(Points)=='number'and Points)or 3;local Main_Model=Instance_2.new('Model',{Parent=workspace;Name=
  23. (function()local a,b='Polygon_',1;for _,c in pairs(workspace:GetDescendants())do if(c.Name):sub(1,a:len())then
  24. b=b+1;end;end;return a..b;end)();});local Center_Point=Instance_2.new('Part',{Parent=Main_Model;Position=
  25. Center;Size=v3_val_1;Anchored=true;});Distance=Distance or 10;for a=1,Points do
  26. local b=Instance_2.new('Part',{Parent=Center_Point;CFrame= CFrame.new(Center_Point.Position)*CFrame.Angles(0,
  27. math.rad(a*(360/Points)),0)*CFrame.new(0,0,-Distance);Anchored=true;});end;return Main_Model;end;
  28.  
  29. CFrame_Angles2=function(x,y,z)local a=math.rad;return CFrame.Angles(a(x),a(y),a(z));end;
  30.  
  31. local function xerror(...)local a,c={...},'';for _,b in pairs(a)do c=c..tostring(b)..' ';end;
  32. spawn(function()error(c);end);wait();end;
  33. --// I ll find a better way i hope
  34.  
  35. local function Get_Union(Primary_Part,table_of_obj,is_negated)
  36.     local parts={Primary_Part};Primary_Part.Parent=workspace;for _,v in pairs(table_of_obj)do
  37.     table.insert(parts,v);v.Anchored=true;v.CanCollide=false;v.Color=Primary_Part.Color;
  38.     v.Transparency=Primary_Part.Transparency;v.Material=Primary_Part.Material;end;
  39.     local union=(not is_negated and Primary_Part:UnionAsync(table_of_obj))or
  40.         Primary_Part:SubtractAsync(table_of_obj);for _,v in pairs(parts)do v:Destroy();
  41.     end;union.Parent=workspace;union.CanCollide=false;return union;end;
  42.  
  43. local function Instance_3(c,p)if not c then return;end;p=p or{};
  44.     local a={};setmetatable(a,{__index={unpack(p);};});
  45.     local b=Instance.new(c,a.Parent);for d,e in pairs(a)do
  46.     local _,f=pcall(function()b[d]=e;end);if f then print(f);end;end;
  47.     return b;end;
  48.  
  49. local function Bevelify(Part_A,Depth)
  50.     local Appearence_Properties={'Color';'Material';'Reflectance';
  51.     'Transparency';};if not Part_A then return;end;Depth=Depth or.02;
  52.     local PA_Size,Negates,mr=Part_A.Size,{},math.rad;
  53.     local function Corner(a,b,c)local d=Instance_3('Part',{Anchored
  54.     =true;CanCollide=false;});for _,e in pairs(Appearence_Properties)
  55.     do pcall(function()d[e]=Part_A[e];end);end;
  56.     d.Size=Vector3.new(Depth*2,PA_Size.Y,PA_Size.Y);
  57.     d.CFrame=Part_A.CFrame*CFrame.new((PA_Size.X/2)*a,(PA_Size.Y/2)*b,
  58.         (PA_Size.Z/2)*c)*CFrame.Angles(0,mr((a==b and((c==a and-45)or
  59.         45))or(c==a and 135)or-135),mr(45));table.insert(Negates,d);
  60.     end;local function Edge(wrap_axis,side_1,side_2)
  61.         local Edge_Part=Instance_3('Part',{Anchored=true;CanCollide=
  62.         false;});for _,a in pairs(Appearence_Properties)do
  63.         pcall(function()Edge_Part[a]=Part_A[a];end);end;
  64.         side_1=-1+(2*side_1);side_2=-1+(2*side_2);
  65.         Edge_Part.Size=Vector3.new((wrap_axis==0 and PA_Size.X)or
  66.             Depth*2,(wrap_axis==1 and PA_Size.Y)or Depth*2,(wrap_axis
  67.             ==2 and PA_Size.Z)or Depth*2);
  68.         Edge_Part.CFrame=Part_A.CFrame*CFrame.new((wrap_axis==0 and
  69.             0)or PA_Size.X/2*side_1,(wrap_axis==1 and 0)or PA_Size.Y/
  70.             2*((wrap_axis==0 and side_1)or(wrap_axis==2 and side_2)),
  71.             (wrap_axis==2 and 0)or PA_Size.Z/2*side_2)*CFrame.Angles(
  72.             (wrap_axis==0 and mr(45))or 0,(wrap_axis==1 and mr(45))or
  73.             0,(wrap_axis==2 and mr(45))or 0);
  74.     table.insert(Negates,Edge_Part);end;local Edge_Data={{0;0;0;};{0;
  75.     0;1;};{0;1;0;};{0;1;1;};{1;0;0;};{1;0;1;};{1;1;0;};{1;1;1;};{2;0;
  76.     0;};{2;0;1;};{2;1;0;};{2;1;1;};};local CornerData={{1;1;1;};{1;1;
  77.     -1;};{1;-1;1;};{-1;1;1;};{-1;-1;1;};{-1;1;-1;};{1;-1;-1;};{-1;-1;
  78.     -1;};};for _,a in pairs(Edge_Data)do Edge(a[1],a[2],a[3]);end;
  79.     for _,a in pairs(CornerData)do Corner(a[1],a[2],a[3]);end;
  80.     local a=Get_Union(Part_A,Negates,true);a.Anchored=true;
  81.     a.Parent=workspace;return a;end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement