DylanD2003

Untitled

Oct 18th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.73 KB | None | 0 0
  1. -- xDarkScripter, Credit to Tinfold for idea | Client Script | Beat
  2.  
  3.  
  4. local Players = game:GetService("Players")
  5. local UserInputService = game:GetService("UserInputService")
  6. local RunService = game:GetService("RunService")
  7.  
  8. local Player = Players.LocalPlayer
  9. local Mouse = Player:GetMouse()
  10. local Camera = workspace.CurrentCamera
  11.  
  12. local Head = Player.Character:FindFirstChild("Head")
  13.  
  14. local BeatCounter = 1
  15.  
  16. local Tune = {BPM = 360, BPU = 4, U = 4}
  17.  
  18. Tune.Sounds = {}
  19.  
  20.  
  21. function Tune:NewSound(Volume, Pitch, SoundId)
  22. local Sound = Instance.new("Sound")
  23.  
  24. Sound.Volume = Volume
  25. Sound.Pitch = Pitch
  26. Sound.SoundId = SoundId
  27.  
  28. return Sound
  29. end
  30.  
  31.  
  32. Tune.Sounds = {
  33. Tune:NewSound(2, 1, "http://www.roblox.com/asset/?id=31173820");
  34. Tune:NewSound(2, 1, "http://www.roblox.com/asset/?id=31173898");
  35. Tune:NewSound(2, 1, "http://www.roblox.com/asset/?id=31173844");
  36. Tune:NewSound(2, 1, "http://www.roblox.com/asset/?id=31173799");
  37. }
  38.  
  39.  
  40. for Key, Sound in next, Tune.Sounds do
  41. Sound.Parent = Head
  42. end
  43.  
  44.  
  45. local BeatTabs = {}
  46.  
  47.  
  48. function Tune:NewBeatTab(Beat, Track, Offset)
  49. local BeatTabIndex = #BeatTabs + 1
  50.  
  51. local Tab = Instance.new("Part")
  52.  
  53. Tab.Anchored, Tab.CanCollide = true, false
  54. Tab.FormFactor, Tab.Material = 3, "SmoothPlastic"
  55. Tab.Size = Vector3.new(0.6, 0.6, 0.6)
  56. Tab.BrickColor = BrickColor.new("Really black")
  57.  
  58. Tab.TopSurface = "SmoothNoOutlines"
  59. Tab.BottomSurface = "SmoothNoOutlines"
  60. Tab.LeftSurface = "SmoothNoOutlines"
  61. Tab.RightSurface = "SmoothNoOutlines"
  62. Tab.FrontSurface = "SmoothNoOutlines"
  63. Tab.BackSurface = "SmoothNoOutlines"
  64.  
  65. local Click = Instance.new("ClickDetector")
  66.  
  67. Click.MouseHoverEnter:connect(function(Activator)
  68. if Activator ~= Player then return end
  69.  
  70. Tab.Size = Vector3.new(0.7, 0.7, 0.7)
  71. end)
  72.  
  73. Click.MouseHoverLeave:connect(function(Activator)
  74. if Activator ~= Player then return end
  75.  
  76. if BeatTabs[BeatTabIndex].Toggled == false then
  77. Tab.Size = Vector3.new(0.6, 0.6, 0.6)
  78. end
  79. end)
  80.  
  81. Click.MouseClick:connect(function(Activator)
  82. if Activator ~= Player then return end
  83.  
  84. Tab.Size = Vector3.new(0.7, 0.7, 0.7)
  85.  
  86. local Toggled = BeatTabs[BeatTabIndex].Toggled
  87.  
  88. BeatTabs[BeatTabIndex].Toggled = not Toggled
  89.  
  90. if Toggled then
  91. Tab.Transparency = 0
  92. Tab.BrickColor = BrickColor.new("Really black")
  93. Tab.Material = "SmoothPlastic"
  94.  
  95. else
  96. Tab.Transparency = 0.2
  97. Tab.BrickColor = BrickColor.new("Cyan")
  98. Tab.Material = "Neon"
  99. end
  100. end)
  101.  
  102. Click.Parent = Tab
  103.  
  104. BeatTabs[BeatTabIndex] = {BasePart = Tab, Offset = Offset, Toggled = false, Track = Track, Beat = Beat}
  105.  
  106. return Tab
  107. end
  108.  
  109. local TuneSounds = #Tune.Sounds
  110. local TotalBeats = Tune.U * Tune.BPU
  111.  
  112. for Row = 1, TuneSounds do
  113. for Beat = 1, TotalBeats do
  114. local BeatTab = Tune:NewBeatTab(Beat, Row, CFrame.new((Beat - 1) * 0.8 - (TotalBeats * 0.4)
  115. , (Row - 1) * 0.8 - (TuneSounds * 0.4), 20 * math.abs(1 - math.cos(math.pi / 4 * ((Beat - 1) - TotalBeats / 2) / TotalBeats))))
  116.  
  117. BeatTab.Parent = workspace
  118. end
  119. end
  120.  
  121.  
  122. function Tune:UpdateTabs()
  123. for Key, Tab in next, BeatTabs do
  124. local GoalCFrame = (Player.Character.PrimaryPart.CFrame * CFrame.new(0, 0, -5) * CFrame.Angles(-math.pi / 8, 0, 0)) * Tab.Offset
  125.  
  126. Tab.BasePart.CFrame = Tab.BasePart.CFrame:Lerp(CFrame.new(GoalCFrame.p, Player.Character.PrimaryPart.Position), 0.1)
  127. end
  128. end
  129.  
  130.  
  131. function Tune:Beat()
  132. if BeatCounter < Tune.U * Tune.BPU then
  133. BeatCounter = BeatCounter + 1
  134.  
  135. else
  136. BeatCounter = 1
  137. end
  138.  
  139. for Key, Tab in next, BeatTabs do
  140. if Tab.Beat == BeatCounter and Tab.Toggled == true then
  141. Tune.Sounds[Tab.Track]:play()
  142. end
  143. end
  144. end
  145.  
  146.  
  147. local Tracker = Instance.new("Part")
  148.  
  149. Tracker.Anchored, Tracker.CanCollide = true, false
  150. Tracker.FormFactor, Tracker.Material = 3, "Neon"
  151. Tracker.Transparency = 0.1
  152. Tracker.Size = Vector3.new(0.4, 0.4, 0.4)
  153. Tracker.BrickColor = BrickColor.White()
  154.  
  155. Tracker.TopSurface = "SmoothNoOutlines"
  156. Tracker.BottomSurface = "SmoothNoOutlines"
  157. Tracker.LeftSurface = "SmoothNoOutlines"
  158. Tracker.RightSurface = "SmoothNoOutlines"
  159. Tracker.FrontSurface = "SmoothNoOutlines"
  160. Tracker.BackSurface = "SmoothNoOutlines"
  161.  
  162. Tracker.Parent = Player.Character
  163.  
  164. function Tune:UpdateTracker()
  165. local TrackerGoalCFrame = (Player.Character.PrimaryPart.CFrame * CFrame.new(0, 0, -5)
  166. * CFrame.Angles(-math.pi / 8, 0, 0)) * CFrame.new((BeatCounter - 1) * 0.8 - (TotalBeats * 0.4), 2, 0)
  167.  
  168. Tracker.CFrame = Tracker.CFrame:Lerp(TrackerGoalCFrame, 0.4)
  169. end
  170.  
  171.  
  172.  
  173.  
  174.  
  175. local PreviousStep
  176.  
  177. RunService.Stepped:connect(function(Step)
  178. if PreviousStep then
  179. if Step - PreviousStep >= 60 / Tune.BPM then
  180. PreviousStep = Step
  181.  
  182. Tune:Beat()
  183. end
  184.  
  185. else
  186. PreviousStep = Step
  187. end
  188.  
  189. Tune:UpdateTabs()
  190. Tune:UpdateTracker()
  191. end)
Add Comment
Please, Sign In to add comment