Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Author: 12GaugeNick
- File-Type: LocalScript
- ]]
- wait()
- -- Setup --
- local MaxBars = 63
- local Height = 40
- local cRot = 1
- local Bars = {}
- local Tweens = {}
- local Floor = math.floor
- local Max = math.max
- local Rad = math.rad
- local Sine = math.sin -- (Yes, it is actually sine)
- local Cos = math.cos
- local Ceil = math.ceil
- local Pi = math.pi
- local Players = game:GetService("Players")
- local AssetService = game:GetService("ContentProvider")
- local RunService = game:GetService("RunService")
- local ServerStorage = game:GetService("ServerStorage")
- local Player = game.Players.LocalPlayer
- local RootPart = function(...) return(Player.Character:WaitForChild("HumanoidRootPart")) end -- The reason I didnt go with Torso, is because its R6 & R15 compatable now :)
- local LastAssetId = 0000000
- local CurrentSong = nil
- local Skip = false
- local AudioIds = {
- 196548598,
- 223648243,
- 144586529,
- 281646839,
- 248217889,
- 239535492,
- 258569613,
- 172522598,
- 381760901,
- 390654737,
- 382412237,
- 200394964,
- 222370123,
- 202148828,
- 289688872,
- 192368758,
- 261454432,
- 206668339,
- 347649273,
- 271068069,
- 225833515,
- 441804774,
- 359339539,
- 268362040,
- }
- -- Functions --
- local function HueCycle(num)
- local Sec = num % 1 * 3
- local Secondary = 0.5 * Pi * (Sec%1)
- if Sec < 1 then
- return 1, 1 - Cos(Secondary), 1 - Sine(Secondary)
- elseif Sec < 2 then
- return 1 - Sine(Secondary), 1, 1 - Cos(Secondary)
- else
- return 1 - Cos(Secondary), 1 - Sine(Secondary), 1
- end
- end
- local function Create(Ins, Table)
- local Obj = Instance.new(Ins)
- for a,b in next,Table do
- Obj[a] = b
- end
- return Obj
- end
- local PlaySong = function(AssetId)
- Sound:Stop()
- Sound.SoundId = "rbxassetid://"..tostring(AssetId)
- AssetService:Preload("rbxassetid://"..tostring(AssetId))
- Sound:Play()
- repeat wait() until (Sound.TimeLength~=0)
- return Sound.TimeLength
- end
- local getNextSong = function()
- return AudioIds[1]
- end
- -- Create the sound --
- local StartSpectrum = function()
- Sound = Create("Sound",{ -- Keep this from being a 'local' because then our PlaySong function can find it :)
- SoundId = "rbxassetid://508162596",
- Volume = 10,
- Looped = true,
- Parent = RootPart()
- })
- -- Create the bars --
- SoundBar = Create("Model",{
- Name = "SoundBar",
- Parent = Player.Character
- })
- for Int = 0,MaxBars do
- local Piece = Create("Part",{
- Name = tostring(Int),
- Size = Vector3.new(0.5, 0.2, 0.5),
- Anchored = true,
- CanCollide = false,
- BottomSurface = Enum.SurfaceType.Smooth,
- TopSurface = Enum.SurfaceType.Smooth,
- Material = 'Neon',
- Parent = SoundBar,
- })
- local Mesh = Create("SpecialMesh",{
- MeshId = "rbxassetid://9856898",
- Scale = Vector3.new(1, 0.400000006, 1),
- TextureId = "rbxassetid://2114473",
- MeshType = Enum.MeshType.FileMesh,
- Parent = Piece,
- })
- table.insert(Bars, Piece)
- end
- end;StartSpectrum()
- SoundBar.Changed:connect(function()
- if SoundBar.Parent == nil or (not SoundBar) then
- StartSpectrum()
- end
- end)
- -- Easing functions --
- local function quadIn(t,b,c,d)
- t=t/d;
- return c*t*t+b;
- end;
- local function quadOut(t,b,c,d)
- t=t/d;
- return -c*t*(t-2)+b;
- end;
- local function Quad(obj,val,ease,d)
- local t,f,con,nt,st,sd=tick()
- Tweens[obj]=t -- Set identifier
- st=obj.Scale.Y -- Start Value
- sd=val-st -- Change in Value
- f=ease=='In' and quadIn or quadOut -- Choose between Out/In
- con=game:GetService'RunService'.RenderStepped:connect(function() nt=tick()-t
- if Tweens[obj]~=t then -- Check for override
- con:disconnect()
- return
- end
- local nv=math.max(.2,f(math.min(d,nt),st,sd,d)) -- New Value
- obj.Scale=Vector3.new(.9,nv,.9)
- obj.Offset=Vector3.new(0,nv/4,0)
- obj.VertexColor = Vector3.new(HueCycle(tick())):lerp(Vector3.new(1,1,1),nv/Height)
- if nt>d then -- Easing done?
- con:disconnect()
- if ease~='In' then
- Quad(obj,.2,'In',.3) -- Drop the bar
- end
- end
- end)
- end
- -- Manipulation of the bars --
- -- (Both of these need to be NOT LOCALIZED)
- local function CheckSet(N,S,D) -- Number, Scale, Direction
- local nS=SoundBar[tostring(N)].Mesh.Scale.Y
- if S>nS then
- Set(N,nS+(S-nS)/3,D)
- end
- end
- function Set(N,S,D) -- Number, Scale, Direction
- Quad(SoundBar[tostring(N)].Mesh,S,'Out',.1) -- Grabs the bar and tweens
- if N>0 and D~=1 then -- Checks left for smaller bars to manipulate
- CheckSet(N-1,S,-1)
- end
- if N<(#Bars-1) and D~=-1 then -- Checks right...
- CheckSet(N+1,S,1)
- end
- end
- -- Move all the bars / make spectrum --
- local MPL,PL,curr = 0
- curr=Sound.SoundId
- spawn(function()
- RunService.RenderStepped:connect(function()
- PL=Sound.PlaybackLoudness
- if Sound.IsPlaying and PL==PL then
- if curr~=Sound.SoundId then
- MPL=0
- curr=Sound.SoundId
- end
- MPL=Max(PL,MPL)
- PL=PL/MPL
- if PL==PL then
- Set(Floor(PL*(#Bars-1)),PL*Height)
- end
- end
- end)
- end)
- -- (This just makes all the bars move)
- spawn(function()
- RunService.RenderStepped:connect(function()
- if SoundBar.Parent ~= nil then
- for Index,Part in next,Bars do
- Part.CFrame = CFrame.new(Player.Character:WaitForChild("HumanoidRootPart").CFrame.p)
- *CFrame.Angles(0, Rad((360/#Bars*Index+(tick()*2)*60/(#Bars ~= 0 and #Bars or 1))%360), 0)
- *CFrame.new(0, -3, (#Bars*.35) + Part.Size.X)
- *CFrame.Angles(0,90,0)
- end
- end
- end)
- end)
- -- Chatted function --
- Player.Chatted:connect(function(Message)
- if Message:lower():sub(0,3) == "/e " then
- Message = Message:sub(4)
- end
- if Message:lower():sub(0,4) == "play" then
- local Int = Message:sub(5)
- if #Int >= 6 then
- PlaySong(tonumber(Int))
- end
- elseif Message:lower():sub(0,4) == "skip" then
- Skip = true
- end
- end)
- -- Create the lovely playlist -- ( Extra feature added by 12GaugeNick :D )
- while wait() do
- for _,v in next,AudioIds do
- Skip = false
- local Delay = PlaySong(v)
- for i = 1,Delay,1 do
- if Skip == true then
- break
- end
- wait(1)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement