Upscalefanatic3

Castle Builder

Oct 19th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. me = game.Players.LocalPlayer
  2.  
  3.  
  4.  
  5. if script.Parent.className ~= "HopperBin" then
  6.  
  7. h = Instance.new("HopperBin")
  8.  
  9. h.Parent = me.Backpack
  10.  
  11. h.Name = "Castle"
  12.  
  13. script.Parent = h
  14.  
  15. end
  16.  
  17.  
  18.  
  19. bin = script.Parent
  20.  
  21.  
  22.  
  23. hold = false
  24.  
  25.  
  26.  
  27. wallbricks = {}
  28.  
  29.  
  30.  
  31. bin.Selected:connect(function(mouse)
  32.  
  33. mouse.Button1Down:connect(function()
  34.  
  35. hold = true
  36.  
  37. local br = Instance.new("Part",me.Character)
  38.  
  39. br.formFactor = 0
  40.  
  41. br.Size = Vector3.new(1,1,1)
  42.  
  43. br.CanCollide = false
  44.  
  45. br.Anchored = true
  46.  
  47. br.TopSurface = 0
  48.  
  49. br.BottomSurface = 0
  50.  
  51. br.CFrame = CFrame.new(mouse.Hit.p)
  52.  
  53. table.insert(wallbricks,br)
  54.  
  55. while hold do
  56.  
  57. wait()
  58.  
  59. br.CFrame = CFrame.new(mouse.Hit.p)
  60.  
  61. end
  62.  
  63. end)
  64.  
  65. mouse.Button1Up:connect(function()
  66.  
  67. hold = false
  68.  
  69. end)
  70.  
  71. mouse.KeyDown:connect(function(key)
  72.  
  73. key = key:lower()
  74.  
  75. if key == "q" then
  76.  
  77. local br = Instance.new("Part",me.Character)
  78.  
  79. br.formFactor = 0
  80.  
  81. br.Size = Vector3.new(1,1,1)
  82.  
  83. br.CanCollide = false
  84.  
  85. br.Anchored = true
  86.  
  87. br.TopSurface = 0
  88.  
  89. br.BottomSurface = 0
  90.  
  91. br.CFrame = CFrame.new(wallbricks[1].Position)
  92.  
  93. table.insert(wallbricks,br)
  94.  
  95. for i=1, #wallbricks do
  96.  
  97. local brick1 = wallbricks[i]
  98.  
  99. local brick2 = wallbricks[i+1]
  100.  
  101. local dist = (brick1.Position - brick2.Position).magnitude
  102.  
  103. local wall = Instance.new("Part")
  104.  
  105. wall.Parent = workspace
  106.  
  107. wall.formFactor = 0
  108.  
  109. wall.Size = Vector3.new(1,8,dist)
  110.  
  111. wall.Anchored = true
  112.  
  113. wall.TopSurface = 0
  114.  
  115. wall.BottomSurface = 0
  116.  
  117. wall.CFrame = CFrame.new(brick1.Position, brick2.Position)
  118.  
  119. wall.CFrame = wall.CFrame * CFrame.new(0,wall.Size.Y/2,-dist/2)
  120.  
  121. end
  122.  
  123. for i=1, #wallbricks do
  124.  
  125. wallbricks[1]:remove()
  126.  
  127. table.remove(wallbricks, 1)
  128.  
  129. end
  130.  
  131. end
  132.  
  133. end)
  134.  
  135. end)
Add Comment
Please, Sign In to add comment