Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.97 KB | None | 0 0
  1. --[[
  2. Author: 12GaugeNick
  3. File-Type: LocalScript
  4. ]]
  5. wait()
  6.  
  7. -- Setup --
  8.  
  9. local MaxBars = 63
  10. local Height = 40
  11. local cRot = 1
  12.  
  13. local Bars = {}
  14. local Tweens = {}
  15.  
  16. local Floor = math.floor
  17. local Max = math.max
  18. local Rad = math.rad
  19. local Sine = math.sin -- (Yes, it is actually sine)
  20. local Cos = math.cos
  21. local Ceil = math.ceil
  22. local Pi = math.pi
  23.  
  24. local Players = game:GetService("Players")
  25. local AssetService = game:GetService("ContentProvider")
  26. local RunService = game:GetService("RunService")
  27. local ServerStorage = game:GetService("ServerStorage")
  28.  
  29. local Player = game.Players.LocalPlayer
  30. local RootPart = function(...) return(Player.Character:WaitForChild("HumanoidRootPart")) end -- The reason I didnt go with Torso, is because its R6 & R15 compatable now :)
  31.  
  32. local LastAssetId = 0000000
  33. local CurrentSong = nil
  34. local Skip = false
  35.  
  36. local AudioIds = {
  37. 196548598,
  38. 223648243,
  39. 144586529,
  40. 281646839,
  41. 248217889,
  42. 239535492,
  43. 258569613,
  44. 172522598,
  45. 381760901,
  46. 390654737,
  47. 382412237,
  48. 200394964,
  49. 222370123,
  50. 202148828,
  51. 289688872,
  52. 192368758,
  53. 261454432,
  54. 206668339,
  55. 347649273,
  56. 271068069,
  57. 225833515,
  58. 441804774,
  59. 359339539,
  60. 268362040,
  61. }
  62.  
  63. -- Functions --
  64.  
  65. local function HueCycle(num)
  66. local Sec = num % 1 * 3
  67. local Secondary = 0.5 * Pi * (Sec%1)
  68. if Sec < 1 then
  69. return 1, 1 - Cos(Secondary), 1 - Sine(Secondary)
  70. elseif Sec < 2 then
  71. return 1 - Sine(Secondary), 1, 1 - Cos(Secondary)
  72. else
  73. return 1 - Cos(Secondary), 1 - Sine(Secondary), 1
  74. end
  75. end
  76.  
  77. local function Create(Ins, Table)
  78. local Obj = Instance.new(Ins)
  79. for a,b in next,Table do
  80. Obj[a] = b
  81. end
  82. return Obj
  83. end
  84.  
  85. local PlaySong = function(AssetId)
  86. Sound:Stop()
  87. Sound.SoundId = "rbxassetid://"..tostring(AssetId)
  88. AssetService:Preload("rbxassetid://"..tostring(AssetId))
  89. Sound:Play()
  90. repeat wait() until (Sound.TimeLength~=0)
  91. return Sound.TimeLength
  92. end
  93.  
  94. local getNextSong = function()
  95. return AudioIds[1]
  96. end
  97.  
  98. -- Create the sound --
  99.  
  100. local StartSpectrum = function()
  101. Sound = Create("Sound",{ -- Keep this from being a 'local' because then our PlaySong function can find it :)
  102. SoundId = "rbxassetid://508162596",
  103. Volume = 10,
  104. Looped = true,
  105. Parent = RootPart()
  106. })
  107.  
  108. -- Create the bars --
  109.  
  110. SoundBar = Create("Model",{
  111. Name = "SoundBar",
  112. Parent = Player.Character
  113. })
  114.  
  115. for Int = 0,MaxBars do
  116. local Piece = Create("Part",{
  117. Name = tostring(Int),
  118. Size = Vector3.new(0.5, 0.2, 0.5),
  119. Anchored = true,
  120. CanCollide = false,
  121. BottomSurface = Enum.SurfaceType.Smooth,
  122. TopSurface = Enum.SurfaceType.Smooth,
  123. Material = 'Neon',
  124. Parent = SoundBar,
  125. })
  126. local Mesh = Create("SpecialMesh",{
  127. MeshId = "rbxassetid://9856898",
  128. Scale = Vector3.new(1, 0.400000006, 1),
  129. TextureId = "rbxassetid://2114473",
  130. MeshType = Enum.MeshType.FileMesh,
  131. Parent = Piece,
  132. })
  133. table.insert(Bars, Piece)
  134. end
  135. end;StartSpectrum()
  136.  
  137. SoundBar.Changed:connect(function()
  138. if SoundBar.Parent == nil or (not SoundBar) then
  139. StartSpectrum()
  140. end
  141. end)
  142.  
  143. -- Easing functions --
  144. local function quadIn(t,b,c,d)
  145. t=t/d;
  146. return c*t*t+b;
  147. end;
  148. local function quadOut(t,b,c,d)
  149. t=t/d;
  150. return -c*t*(t-2)+b;
  151. end;
  152. local function Quad(obj,val,ease,d)
  153. local t,f,con,nt,st,sd=tick()
  154. Tweens[obj]=t -- Set identifier
  155. st=obj.Scale.Y -- Start Value
  156. sd=val-st -- Change in Value
  157. f=ease=='In' and quadIn or quadOut -- Choose between Out/In
  158. con=game:GetService'RunService'.RenderStepped:connect(function() nt=tick()-t
  159. if Tweens[obj]~=t then -- Check for override
  160. con:disconnect()
  161. return
  162. end
  163. local nv=math.max(.2,f(math.min(d,nt),st,sd,d)) -- New Value
  164. obj.Scale=Vector3.new(.9,nv,.9)
  165. obj.Offset=Vector3.new(0,nv/4,0)
  166. obj.VertexColor = Vector3.new(HueCycle(tick())):lerp(Vector3.new(1,1,1),nv/Height)
  167. if nt>d then -- Easing done?
  168. con:disconnect()
  169. if ease~='In' then
  170. Quad(obj,.2,'In',.3) -- Drop the bar
  171. end
  172. end
  173. end)
  174. end
  175.  
  176. -- Manipulation of the bars --
  177. -- (Both of these need to be NOT LOCALIZED)
  178. local function CheckSet(N,S,D) -- Number, Scale, Direction
  179. local nS=SoundBar[tostring(N)].Mesh.Scale.Y
  180. if S>nS then
  181. Set(N,nS+(S-nS)/3,D)
  182. end
  183. end
  184.  
  185. function Set(N,S,D) -- Number, Scale, Direction
  186. Quad(SoundBar[tostring(N)].Mesh,S,'Out',.1) -- Grabs the bar and tweens
  187. if N>0 and D~=1 then -- Checks left for smaller bars to manipulate
  188. CheckSet(N-1,S,-1)
  189. end
  190. if N<(#Bars-1) and D~=-1 then -- Checks right...
  191. CheckSet(N+1,S,1)
  192. end
  193. end
  194.  
  195.  
  196. -- Move all the bars / make spectrum --
  197. local MPL,PL,curr = 0
  198. curr=Sound.SoundId
  199. spawn(function()
  200. RunService.RenderStepped:connect(function()
  201. PL=Sound.PlaybackLoudness
  202. if Sound.IsPlaying and PL==PL then
  203. if curr~=Sound.SoundId then
  204. MPL=0
  205. curr=Sound.SoundId
  206. end
  207. MPL=Max(PL,MPL)
  208. PL=PL/MPL
  209. if PL==PL then
  210. Set(Floor(PL*(#Bars-1)),PL*Height)
  211. end
  212. end
  213. end)
  214. end)
  215.  
  216. -- (This just makes all the bars move)
  217. spawn(function()
  218. RunService.RenderStepped:connect(function()
  219. if SoundBar.Parent ~= nil then
  220. for Index,Part in next,Bars do
  221. Part.CFrame = CFrame.new(Player.Character:WaitForChild("HumanoidRootPart").CFrame.p)
  222. *CFrame.Angles(0, Rad((360/#Bars*Index+(tick()*2)*60/(#Bars ~= 0 and #Bars or 1))%360), 0)
  223. *CFrame.new(0, -3, (#Bars*.35) + Part.Size.X)
  224. *CFrame.Angles(0,90,0)
  225. end
  226. end
  227. end)
  228. end)
  229.  
  230. -- Chatted function --
  231. Player.Chatted:connect(function(Message)
  232. if Message:lower():sub(0,3) == "/e " then
  233. Message = Message:sub(4)
  234. end
  235. if Message:lower():sub(0,4) == "play" then
  236. local Int = Message:sub(5)
  237. if #Int >= 6 then
  238. PlaySong(tonumber(Int))
  239. end
  240. elseif Message:lower():sub(0,4) == "skip" then
  241. Skip = true
  242. end
  243. end)
  244.  
  245. -- Create the lovely playlist -- ( Extra feature added by 12GaugeNick :D )
  246. while wait() do
  247. for _,v in next,AudioIds do
  248. Skip = false
  249. local Delay = PlaySong(v)
  250. for i = 1,Delay,1 do
  251. if Skip == true then
  252. break
  253. end
  254. wait(1)
  255. end
  256. end
  257. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement