Advertisement
Velinquish

Stack

Apr 27th, 2021
814
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.36 KB | None | 0 0
  1. local TweenService = game:GetService("TweenService")
  2. local Players = game.Players
  3.  
  4. camera = workspace.CurrentCamera
  5. camera.CameraType = Enum.CameraType.Scriptable
  6.  
  7. local index = 0
  8. local height = 0.5
  9. local previousPart = Instance.new("Part")
  10. previousPart.Size = Vector3.new(10, 1, 8)
  11. previousPart.Material = Enum.Material.SmoothPlastic
  12. previousPart.Parent = workspace
  13.  
  14. camera.CFrame = CFrame.lookAt(Vector3.new(1, 15, 6), previousPart.Position)
  15. local cameraCf = camera.CFrame
  16.  
  17. wait(2)
  18.  
  19.  
  20. while true do
  21.     height += 1
  22.     index += 1
  23.     local part = Instance.new("Part")
  24.     part.Anchored = true
  25.     part.Material = Enum.Material.SmoothPlastic
  26.     part.Size = previousPart.Size
  27.     part.CFrame = previousPart.CFrame + Vector3.new(index % 2 == 0 and 8 or -8, 5.5, 0)
  28.     part.Parent = workspace
  29.     cameraCf += Vector3.new(0, 1, 0)
  30.     TweenService:Create(camera, TweenInfo.new(0.8), {
  31.         CFrame = cameraCf
  32.     }):Play()
  33.     local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true)
  34.     local tween = TweenService:Create(part, tweenInfo, {
  35.         CFrame = previousPart.CFrame + Vector3.new(index % 2 == 0 and -8 or 8, 5.5, 0)
  36.     })
  37.     tween:Play()
  38.     Players.LocalPlayer:GetMouse().Button1Up:Wait()
  39.     tween:Cancel()
  40.    
  41.     local shrinkBy = math.abs(previousPart.Position.X - part.Position.X)
  42.     if shrinkBy > part.Size.X then
  43.         print("Final score:", index)
  44.         part.Anchored = false
  45.         part.CanCollide = false
  46.         break
  47.     end
  48.    
  49.     tween = TweenService:Create(part, TweenInfo.new(0.4, Enum.EasingStyle.Quad), {
  50.         Position = Vector3.new(part.Position.X, height, part.Position.Z)
  51.     })
  52.     tween:Play()
  53.     tween.Completed:Wait()
  54.    
  55.     -- Some visual effects, cutting off a piece of the block and letting it fall
  56.     local slice = Instance.new("Part")
  57.     slice.CanCollide = false -- Let it fall through the floor into oblivion
  58.     slice.Material = Enum.Material.SmoothPlastic
  59.     slice.Size = Vector3.new(shrinkBy, 1, 8)
  60.    
  61.     part.Size = Vector3.new(part.Size.X - shrinkBy, 1, 8)
  62.     if part.Position.X < previousPart.Position.X then
  63.         part.CFrame += Vector3.new(shrinkBy / 2, 0, 0)
  64.         slice.CFrame = part.CFrame - Vector3.new(part.Size.X/2, 0, 0) - Vector3.new(shrinkBy/2, 0, 0)
  65.     else
  66.         part.CFrame -= Vector3.new(shrinkBy / 2, 0, 0)
  67.         slice.CFrame = part.CFrame + Vector3.new(part.Size.X/2, 0, 0) + Vector3.new(shrinkBy/2, 0, 0)
  68.     end
  69.     slice.Parent = workspace
  70.    
  71.     previousPart = part
  72.     print(index)
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement