Advertisement
TheUnknownDiscord

musicbox

Feb 22nd, 2022 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.44 KB | None | 0 0
  1. local PartA = Instance.new("Part")
  2. PartA.Transparency = 1
  3. PartA.CanCollide = false
  4. local SA = Instance.new("Sound",PartA)
  5. SA.SoundId = "rbxasset://sounds/bass.mp3"
  6. SA.PlayOnRemove = true
  7. SA.TimePosition = 0.2
  8. local PartB = Instance.new("Part")
  9. PartB.Transparency = 1
  10. PartB.CanCollide = false
  11. local SB = Instance.new("Sound",PartB)
  12. SB.SoundId = "rbxasset://sounds/snap.mp3"
  13. SB.PlayOnRemove = true
  14. SB.TimePosition = 0.2
  15. local PartC = Instance.new("Part")
  16. PartC.Transparency = 1
  17. PartC.CanCollide = false
  18. local SC = Instance.new("Sound",PartC)
  19. SC.SoundId = "rbxasset://sounds/bass.mp3"
  20. SC.PlayOnRemove = true
  21. SC.TimePosition = 0.2
  22. PartA.Anchored = true
  23. PartB.Anchored = true
  24. PartC.Anchored = true
  25. local SoundCount = 0
  26. function PlayFX(type,pitch,vol,pos)
  27. coroutine.wrap(function()
  28. if SoundCount < 30 then
  29. local waiter = 0
  30. local Part,Sound
  31. if type == "A" then
  32. Part,Sound,waiter = PartA,SA,1
  33. elseif type == "B" then
  34. Part,Sound,waiter = PartB,SB,0.4
  35. elseif type == "C" then
  36. Part,Sound,waiter = PartC,SC,0.4
  37. end
  38. Sound.PlaybackSpeed = pitch
  39. Sound.Volume = vol
  40. Part.Position = pos
  41. Part.Parent = script
  42. Part.Parent = nil
  43. SoundCount = SoundCount + 1
  44. delay(waiter/pitch,function()
  45. SoundCount = SoundCount - 1
  46. end)
  47. end
  48. end)()
  49. end
  50. local p,p2,p3,p4,p5 = Instance.new("Part",script),Instance.new("Part",script),Instance.new("Part",script),Instance.new("Part",script),Instance.new("Part",script)
  51. p.Anchored = true
  52. p2.Anchored = true
  53. p3.Anchored = true
  54. p4.Anchored = true
  55. p5.Anchored = true
  56. p.CanCollide = false
  57. p2.CanCollide = false
  58. p3.CanCollide = false
  59. p4.CanCollide = false
  60. p5.CanCollide = false
  61. p.Size = Vector3.new(1,1,2)
  62. p.CFrame = CFrame.new(5,3,5)
  63. p2.Size = Vector3.new(1,1,2)
  64. p2.CFrame = CFrame.new(6.5,3,5)
  65. p3.Size = Vector3.new(1,1,2)
  66. p3.CFrame = CFrame.new(8,3,5)
  67. p4.Size = Vector3.new(1,1,2)
  68. p4.CFrame = CFrame.new(9.5,3,5)
  69. p5.Size = Vector3.new(1,1,2)
  70. p5.CFrame = CFrame.new(11,3,5)
  71. wait(0.5)
  72. local db, db2,db3,db4,db5 = false,false,false,false,false
  73. p.Touched:Connect(function()
  74. if not db then
  75. db = true
  76. PlayFX("B",1.75,2,p.Position)
  77. local tweenService = game:GetService("TweenService")
  78. local object = p
  79. local tweenInfo = TweenInfo.new(0.5)
  80. local goal = {}
  81. goal.CFrame = CFrame.new(p.Position) * CFrame.Angles(math.rad(20),0,0)
  82. local tween = tweenService:Create(object, tweenInfo, goal)
  83. tween:Play()
  84. delay(1, function()
  85. local tweenService = game:GetService("TweenService")
  86. local object = p
  87. local tweenInfo = TweenInfo.new(0.5)
  88. local goal = {}
  89. goal.CFrame = CFrame.new(p.Position)
  90. local tween = tweenService:Create(object, tweenInfo, goal)
  91. tween:Play()
  92. db = false
  93. end)
  94. end
  95. end)
  96. p2.Touched:Connect(function()
  97. if not db2 then
  98. db2 = true
  99. PlayFX("C",3,2,p2.Position)
  100. local tweenService = game:GetService("TweenService")
  101. local object = p2
  102. local tweenInfo = TweenInfo.new(0.5)
  103. local goal = {}
  104. goal.CFrame = CFrame.new(p2.Position) * CFrame.Angles(math.rad(20),0,0)
  105. local tween = tweenService:Create(object, tweenInfo, goal)
  106. tween:Play()
  107. delay(1, function()
  108. local tweenService = game:GetService("TweenService")
  109. local object = p2
  110. local tweenInfo = TweenInfo.new(0.5)
  111. local goal = {}
  112. goal.CFrame = CFrame.new(p2.Position)
  113. local tween = tweenService:Create(object, tweenInfo, goal)
  114. tween:Play()
  115. db2 = false
  116. end)
  117. end
  118. end)
  119. p3.Touched:Connect(function()
  120. if not db3 then
  121. db3 = true
  122. PlayFX("C",3.75,2,p3.Position)
  123. local tweenService = game:GetService("TweenService")
  124. local object = p3
  125. local tweenInfo = TweenInfo.new(0.5)
  126. local goal = {}
  127. goal.CFrame = CFrame.new(p3.Position) * CFrame.Angles(math.rad(20),0,0)
  128. local tween = tweenService:Create(object, tweenInfo, goal)
  129. tween:Play()
  130. delay(1, function()
  131. local tweenService = game:GetService("TweenService")
  132. local object = p3
  133. local tweenInfo = TweenInfo.new(0.5)
  134. local goal = {}
  135. goal.CFrame = CFrame.new(p3.Position)
  136. local tween = tweenService:Create(object, tweenInfo, goal)
  137. tween:Play()
  138. db3 = false
  139. end)
  140. end
  141. end)
  142. p4.Touched:Connect(function()
  143. if not db4 then
  144. db4 = true
  145. PlayFX("C",4.5,2,p4.Position)
  146. local tweenService = game:GetService("TweenService")
  147. local object = p4
  148. local tweenInfo = TweenInfo.new(0.5)
  149. local goal = {}
  150. goal.CFrame = CFrame.new(p4.Position) * CFrame.Angles(math.rad(20),0,0)
  151. local tween = tweenService:Create(object, tweenInfo, goal)
  152. tween:Play()
  153. delay(1, function()
  154. local tweenService = game:GetService("TweenService")
  155. local object = p4
  156. local tweenInfo = TweenInfo.new(0.5)
  157. local goal = {}
  158. goal.CFrame = CFrame.new(p4.Position)
  159. local tween = tweenService:Create(object, tweenInfo, goal)
  160. tween:Play()
  161. db4 = false
  162. end)
  163. end
  164. end)
  165. p5.Touched:Connect(function()
  166. if not db5 then
  167. db5 = true
  168. PlayFX("C",5,2,p5.Position)
  169. local tweenService = game:GetService("TweenService")
  170. local object = p5
  171. local tweenInfo = TweenInfo.new(0.5)
  172. local goal = {}
  173. goal.CFrame = CFrame.new(p5.Position) * CFrame.Angles(math.rad(20),0,0)
  174. local tween = tweenService:Create(object, tweenInfo, goal)
  175. tween:Play()
  176. delay(1, function()
  177. local tweenService = game:GetService("TweenService")
  178. local object = p5
  179. local tweenInfo = TweenInfo.new(0.5)
  180. local goal = {}
  181. goal.CFrame = CFrame.new(p5.Position)
  182. local tween = tweenService:Create(object, tweenInfo, goal)
  183. tween:Play()
  184. db5 = false
  185. end)
  186. end
  187. end)
  188. local parts = {}
  189. rail = Instance.new("Part",script)
  190. local at2 = Instance.new("Attachment" , workspace.Terrain)
  191. at2.CFrame = CFrame.new(3.5,5,2) * CFrame.Angles(0,math.rad(90),0)
  192. local at3 = Instance.new("Attachment" , rail)
  193. at3.CFrame = CFrame.Angles(0,math.rad(90),0)
  194. local prism2 = Instance.new("PrismaticConstraint" , rail)
  195. prism2.Attachment0 = at2
  196. prism2.Attachment1 = at3
  197. prism2.LimitsEnabled = true
  198. prism2.LowerLimit = -100
  199. prism2.UpperLimit = 100
  200. local bp = Instance.new("BodyPosition",rail)
  201. bp.P = 1000000000000
  202. bp.Position = Vector3.new(3.5,5,2)
  203. local bg = Instance.new("BodyGyro",rail)
  204. bg.P = 100000
  205. bg.MaxTorque = Vector3.new(100000000000,100000000000,100000000000)
  206. rail.CFrame = CFrame.new(3.5,5,2)
  207. local lastcf = CFrame.new(3.5,3,2)
  208. local lastcf2 = CFrame.new(0,0,0)
  209. for i = 1, 5 do
  210. local p = Instance.new("SpawnLocation",script)
  211. p.Enabled = false
  212. p.Anchored = true
  213. p.CFrame = lastcf * CFrame.new(1.5,0,0)
  214. p.Size = Vector3.new(1,1,1)
  215. lastcf = p.CFrame
  216. lastcf2 = lastcf
  217. local clickDetector = Instance.new("ClickDetector")
  218. clickDetector.Parent = p
  219. clickDetector.MaxActivationDistance = 50
  220. clickDetector.MouseClick:Connect(function(plr)
  221. if plr == owner then
  222. p.Color = Color3.new()
  223. end
  224. end)
  225. table.insert(parts,p)
  226. for i = 1, 21 - 1 do
  227. local p = Instance.new("SpawnLocation",script)
  228. p.Enabled = false
  229. p.Anchored = true
  230. p.Size = Vector3.new(1,1,1)
  231. p.CFrame = lastcf2 * CFrame.new(0,0,-1.5)
  232. lastcf2 = p.CFrame
  233. local clickDetector = Instance.new("ClickDetector")
  234. clickDetector.Parent = p
  235. clickDetector.MaxActivationDistance = 50
  236. clickDetector.MouseClick:Connect(function(plr)
  237. if plr == owner then
  238. p.Color = Color3.new()
  239. end
  240. end)
  241. table.insert(parts,p)
  242. end
  243. end
  244. owner.Chatted:Connect(function(msg)
  245. if msg == "!start" then
  246. for i,v in pairs(parts) do
  247. if v.Color ~= Color3.new() then
  248. v:Destroy()
  249. else
  250. local weld = Instance.new("WeldConstraint",rail)
  251. weld.Part0 = v
  252. weld.Part1 = rail
  253. v.Anchored = false
  254. end
  255. end
  256. local tweenService = game:GetService("TweenService")
  257. local object = bp
  258. local tweenInfo = TweenInfo.new(4)
  259. local goal = {}
  260. goal.Position = Vector3.new(3.5,5,40)
  261. local tween = tweenService:Create(object, tweenInfo, goal)
  262. tween:Play()
  263. end
  264. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement