KrYn0MoRe

music box

Jul 24th, 2020 (edited)
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.49 KB | None | 0 0
  1. Model0 = Instance.new("Model")
  2. Part1 = Instance.new("Part")
  3. Part2 = Instance.new("Part")
  4. ClickDetector3 = Instance.new("ClickDetector")
  5. Model4 = Instance.new("Model")
  6. Part5 = Instance.new("Part")
  7. Part6 = Instance.new("Part")
  8. Part7 = Instance.new("Part")
  9. Model0.Name = "music box"
  10. Model0.Parent = script
  11. Part1.Parent = Model0
  12. Part1.CFrame = CFrame.new(-6.70001221, 9.5, -18.6999817, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  13. Part1.Position = Vector3.new(-6.70001221, 9.5, -18.6999817)
  14. Part1.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  15. Part1.Size = Vector3.new(9, 1, 9)
  16. Part1.Anchored = true
  17. Part1.BottomSurface = Enum.SurfaceType.Smooth
  18. Part1.BrickColor = BrickColor.new("Really black")
  19. Part1.TopSurface = Enum.SurfaceType.Smooth
  20. Part1.brickColor = BrickColor.new("Really black")
  21. Part2.Name = "click"
  22. Part2.Parent = Model0
  23. Part2.CFrame = CFrame.new(-6.70001221, 5.400002, -18.6999817, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  24. Part2.Position = Vector3.new(-6.70001221, 5.400002, -18.6999817)
  25. Part2.Color = Color3.new(1, 1, 0)
  26. Part2.Transparency = 1
  27. Part2.Size = Vector3.new(11, 10.8000002, 11)
  28. Part2.Anchored = true
  29. Part2.BottomSurface = Enum.SurfaceType.Smooth
  30. Part2.BrickColor = BrickColor.new("New Yeller")
  31. Part2.TopSurface = Enum.SurfaceType.Smooth
  32. Part2.brickColor = BrickColor.new("New Yeller")
  33. ClickDetector3.Parent = Part2
  34. ClickDetector3.MaxActivationDistance = 10
  35. Model4.Name = "color"
  36. Model4.Parent = Model0
  37. Part5.Parent = Model4
  38. Part5.CFrame = CFrame.new(-6.70001221, 9.5, -18.6999817, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  39. Part5.Orientation = Vector3.new(0, 90, 0)
  40. Part5.Position = Vector3.new(-6.70001221, 9.5, -18.6999817)
  41. Part5.Rotation = Vector3.new(0, 90, 0)
  42. Part5.Color = Color3.new(0, 1, 1)
  43. Part5.Size = Vector3.new(1, 1.20000005, 9.19999981)
  44. Part5.Anchored = true
  45. Part5.BottomSurface = Enum.SurfaceType.Smooth
  46. Part5.BrickColor = BrickColor.new("Toothpaste")
  47. Part5.TopSurface = Enum.SurfaceType.Smooth
  48. Part5.brickColor = BrickColor.new("Toothpaste")
  49. Part6.Parent = Model4
  50. Part6.CFrame = CFrame.new(-6.70001221, 9.5, -18.6999817, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  51. Part6.Position = Vector3.new(-6.70001221, 9.5, -18.6999817)
  52. Part6.Color = Color3.new(0, 1, 1)
  53. Part6.Size = Vector3.new(1, 1.20000005, 9.19999981)
  54. Part6.Anchored = true
  55. Part6.BottomSurface = Enum.SurfaceType.Smooth
  56. Part6.BrickColor = BrickColor.new("Toothpaste")
  57. Part6.TopSurface = Enum.SurfaceType.Smooth
  58. Part6.brickColor = BrickColor.new("Toothpaste")
  59. Part7.Parent = Model4
  60. Part7.CFrame = CFrame.new(-6.70001221, 4.5, -18.6999817, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  61. Part7.Position = Vector3.new(-6.70001221, 4.5, -18.6999817)
  62. Part7.Color = Color3.new(0, 1, 1)
  63. Part7.Size = Vector3.new(9, 9, 9)
  64. Part7.Anchored = true
  65. Part7.BottomSurface = Enum.SurfaceType.Smooth
  66. Part7.BrickColor = BrickColor.new("Toothpaste")
  67. Part7.TopSurface = Enum.SurfaceType.Smooth
  68. Part7.brickColor = BrickColor.new("Toothpaste")
  69.  
  70. local colors = script['music box']['color']
  71. local click = script['music box']['click']:FindFirstChildOfClass("ClickDetector")
  72. local click2 = click.Parent
  73. local max_timer = 30
  74. local timer = 0
  75. local tweening = false
  76.  
  77. click2.CanCollide = false
  78.  
  79. local theme = Instance.new("Sound")
  80. theme.SoundId = 'rbxassetid://186847938'
  81. theme.Volume = 1
  82. theme.Looped = true
  83. theme.Parent = click2
  84. theme:Play()
  85.  
  86. local tween = Instance.new("Sound")
  87. tween.SoundId = 'rbxassetid://209530691'
  88. tween.Volume = 0.3
  89. tween.Looped = false
  90. tween.Parent = click2
  91.  
  92. click.MouseClick:Connect(function()
  93.     if not tweening then else return end
  94.     tweening = true
  95.     click.Parent = nil
  96.     timer = timer - 10
  97.     if 0 > timer then
  98.         timer = 0
  99.     end
  100.     tween:Play()
  101.     wait(3)
  102.     click.Parent = click2
  103.     tweening = false
  104. end)
  105.  
  106. function explode()
  107.     local exp = Instance.new("Explosion")
  108.     exp.Position = click2.Position
  109.     exp.BlastRadius = 30
  110.     exp.DestroyJointRadiusPercent = 1
  111.     exp.ExplosionType = Enum.ExplosionType.Craters
  112.     exp.Parent = click2
  113.     theme:Stop()
  114.     local exp_s = Instance.new("Sound")
  115.     exp_s.SoundId = 'rbxassetid://2770705979'
  116.     exp_s.Volume = 10
  117.     exp_s.Looped = false
  118.     exp_s.Parent = click2
  119.     exp_s:Play()
  120.     exp.Hit:Connect(function(hit,dist)
  121.         hit.Anchored = false
  122.     end)
  123. end
  124.  
  125. function change_color()
  126.     local r,g,b = 0,1,1
  127.     local t = timer
  128.     if (t > max_timer) then
  129.         t = max_timer
  130.     end
  131.     t = t/max_timer
  132.     r = t
  133.     g = g-r
  134.     b = b-r
  135.     for i,v in ipairs(colors:GetChildren()) do
  136.         game:GetService("TweenService"):Create(v,TweenInfo.new(1),{Color = Color3.new(r,g,b)}):Play()
  137.     end
  138. end
  139.  
  140. while max_timer >= timer do
  141.     wait(1)
  142.     timer = timer + 1
  143.     change_color()
  144. end
  145.  
  146. explode()
Add Comment
Please, Sign In to add comment