Advertisement
DevSarim

Windows

Jan 27th, 2023
780
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. function API:PositionAround(wall: BasePart, window: BasePart)
  2.     local aPos = wall.Position
  3.     local aSize = wall.Size
  4.  
  5.     local bPos = window.Position
  6.     local bSize = window.Size
  7.  
  8.     local pos1 = wall.CFrame * CFrame.new(0, aSize.Y / 2, aSize.Z / 2)
  9.     local pos2 = wall.CFrame * CFrame.new(0, aSize.Y / 2, -(aSize.Z / 2))
  10.     local pos3 = wall.CFrame * CFrame.new(0, -(aSize.Y / 2), aSize.Z / 2)
  11.     local pos4 = wall.CFrame * CFrame.new(0, -(aSize.Y / 2), -(aSize.Z / 2))
  12.  
  13.     local pos5 = window.CFrame * CFrame.new(0, bSize.Y / 2, bSize.Z / 2)
  14.     local pos6 = window.CFrame * CFrame.new(0, bSize.Y / 2, -(bSize.Z / 2))
  15.     local pos7 = window.CFrame * CFrame.new(0, -(bSize.Y / 2), bSize.Z / 2)
  16.     local pos8 = window.CFrame * CFrame.new(0, -(bSize.Y / 2), -(bSize.Z / 2))
  17.    
  18.     CreatePartAt(pos1, Color3.new(1, 0, 0))
  19.     CreatePartAt(pos2, Color3.new(1, 1, 0))
  20.     CreatePartAt(pos3)
  21.     CreatePartAt(pos4)
  22.     CreatePartAt(pos5, Color3.new(0, 1, 0))
  23.     CreatePartAt(pos6, Color3.new(0, 0, 1))
  24.     CreatePartAt(pos7)
  25.     CreatePartAt(pos8)
  26.  
  27.     local sectionSize1 = math.abs(pos1.Position.Z - pos5.Position.Z)
  28.     local sectionSize3 = math.abs(pos6.Position.Z - pos2.Position.Z)
  29.    
  30.     print(sectionSize1, sectionSize3)
  31.  
  32.     local sectionSize2 = math.abs(pos1.Position.Y - pos5.Position.Y)
  33.     local sectionSize4 = math.abs(pos3.Position.Y - pos7.Position.Y)
  34.  
  35.     PrefabSection1.Size = Vector3.new(aSize.X, aSize.Y, sectionSize1)
  36.     PrefabSection2.Size = Vector3.new(aSize.X, sectionSize2, bSize.Z)
  37.     PrefabSection3.Size = Vector3.new(aSize.X, aSize.Y, sectionSize3)
  38.     PrefabSection4.Size = Vector3.new(aSize.X, sectionSize4, bSize.Z)
  39.  
  40.     PrefabSection1.CFrame = pos1 * CFrame.new(0, -(aSize.Y / 2), -(sectionSize1 / 2)) --CFrame.new(Vector3.new(aPos.X, aPos.Y, pos1.Z - sectionSize1 / 2)) * wall.CFrame.Rotation
  41.     PrefabSection2.CFrame = pos5 * CFrame.new(0, (sectionSize2 / 2), -(bSize.Z / 2))
  42.     PrefabSection3.CFrame = pos2 * CFrame.new(0, -(aSize.Y / 2), (sectionSize3 / 2)) --CFrame.new(Vector3.new(aPos.X, aPos.Y, pos2.Z + sectionSize3 / 2)) * wall.CFrame.Rotation
  43.     PrefabSection4.CFrame = pos7 * CFrame.new(0, -(sectionSize4 / 2), -(bSize.Z / 2)) --CFrame.new(Vector3.new(aPos.X, pos7.Y - sectionSize4 / 2, bPos.Z)) * wall.CFrame.Rotation
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement