Advertisement
Guest User

Untitled

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