Advertisement
level7executor

Music bar

Mar 1st, 2017
1,199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.99 KB | None | 0 0
  1. player = game.Players.LocalPlayer
  2. wait()
  3. script.Parent=nil
  4. active = true
  5. Settings = {
  6.     Prefix = "";
  7.     LerpSpeed = .5;
  8.     MusicLerp = .3;
  9.     Distance = .5;
  10.     Range = 15;
  11.     Height = 4;
  12. }
  13.  
  14. function SpawnBars()
  15.     partmiddle = Instance.new("Part")
  16.     partmiddle.Name = "Bars___"..player.Name
  17.     partmiddle.Size = Vector3.new(.2,4,.2)
  18.     partmiddle.Parent = player.Character
  19.     partmiddle.Anchored = true
  20.     partmiddle.Material = "Neon"
  21.     partmiddle.CanCollide = false
  22.     partleft = partmiddle:Clone()
  23.     partright = partmiddle:Clone()
  24.     partleftfar = partmiddle:Clone()
  25.     partrightfar = partmiddle:Clone()
  26.     partleftfarfar = partmiddle:Clone()
  27.     partrightfarfar = partmiddle:Clone()
  28.     partleftfarfarfar = partmiddle:Clone()
  29.     partrightfarfarfar = partmiddle:Clone()
  30.     partleftfarest = partmiddle:Clone()
  31.     partrightfarest = partmiddle:Clone()
  32.     partleftfarestfar = partmiddle:Clone()
  33.     partrightfarestfar = partmiddle:Clone()
  34.     partleft.Parent = partmiddle
  35.     partright.Parent = partmiddle
  36.     partleftfar.Parent = partmiddle
  37.     partrightfar.Parent = partmiddle
  38.     partleftfarfar.Parent = partmiddle
  39.     partrightfarfar.Parent = partmiddle
  40.     partleftfarfarfar.Parent = partmiddle
  41.     partrightfarfarfar.Parent = partmiddle
  42.     partleftfarest.Parent = partmiddle
  43.     partrightfarest.Parent = partmiddle
  44.     partleftfarestfar.Parent = partmiddle
  45.     partrightfarestfar.Parent = partmiddle
  46. end
  47. function SpawnMusic()
  48.     Sound = Instance.new('Sound',partmiddle)
  49.     Sound.EmitterSize = Settings.Range
  50.     Sound.Looped = true
  51.     Sound.Volume = 1
  52.     Sound:Play()
  53. end
  54.  
  55. game:GetService'RunService'.RenderStepped:connect(function()
  56.     if not active then return end
  57.     if not player.Character:FindFirstChild('Bars___'..player.Name) then
  58.         SpawnBars()
  59.         wait()
  60.     end
  61.     if not player.Character:FindFirstChild('Bars___'..player.Name):FindFirstChild('Sound') then
  62.         SpawnMusic()
  63.         wait()
  64.     else
  65.         if Sound.PlaybackLoudness >= 350 then
  66.             partmiddle.BrickColor = BrickColor.Random()
  67.         end
  68.     end
  69.     pcall(function()
  70.         partmiddle.CFrame = partmiddle.CFrame:Lerp(player.Character.HumanoidRootPart.CFrame*CFrame.new(0,Settings.Height,3),Settings.LerpSpeed)
  71.         partleft.CFrame = partleft.CFrame:Lerp(partmiddle.CFrame*CFrame.new(-Settings.Distance,0,0),Settings.LerpSpeed)
  72.         partright.CFrame = partright.CFrame:Lerp(partmiddle.CFrame*CFrame.new(Settings.Distance,0,0),Settings.LerpSpeed)
  73.         partleftfar.CFrame = partleftfar.CFrame:Lerp(partleft.CFrame*CFrame.new(-Settings.Distance,0,0),Settings.LerpSpeed)
  74.         partrightfar.CFrame = partrightfar.CFrame:Lerp(partright.CFrame*CFrame.new(Settings.Distance,0,0),Settings.LerpSpeed)
  75.         partleftfarfar.CFrame = partleftfarfar.CFrame:Lerp(partleftfar.CFrame*CFrame.new(-Settings.Distance,0,0),Settings.LerpSpeed)
  76.         partrightfarfar.CFrame = partrightfarfar.CFrame:Lerp(partrightfar.CFrame*CFrame.new(Settings.Distance,0,0),Settings.LerpSpeed)
  77.         partleftfarfarfar.CFrame = partleftfarfarfar.CFrame:Lerp(partleftfarfar.CFrame*CFrame.new(-Settings.Distance,0,0),Settings.LerpSpeed)
  78.         partrightfarfarfar.CFrame = partrightfarfarfar.CFrame:Lerp(partrightfarfar.CFrame*CFrame.new(Settings.Distance,0,0),Settings.LerpSpeed)
  79.         partleftfarest.CFrame = partleftfarest.CFrame:Lerp(partleftfarfarfar.CFrame*CFrame.new(-Settings.Distance,0,0),Settings.LerpSpeed)
  80.         partrightfarest.CFrame = partrightfarest.CFrame:Lerp(partrightfarfarfar.CFrame*CFrame.new(Settings.Distance,0,0),Settings.LerpSpeed)
  81.         partleftfarestfar.CFrame = partleftfarestfar.CFrame:Lerp(partleftfarest.CFrame*CFrame.new(-Settings.Distance,0,0),Settings.LerpSpeed)
  82.         partrightfarestfar.CFrame = partrightfarestfar.CFrame:Lerp(partrightfarest.CFrame*CFrame.new(Settings.Distance,0,0),Settings.LerpSpeed)
  83.     end)
  84.     local Color =  partmiddle.BrickColor
  85.     local Color_2 = partleft.BrickColor
  86.     local Color_3 = partleftfar.BrickColor
  87.     local Color_4 = partleftfarfar.BrickColor
  88.     local Color_5 = partleftfarfarfar.BrickColor
  89.     local Prev_Size = partmiddle.Size
  90.     local Prev_Size2 = partleft.Size
  91.     local Prev_Size3 = partleftfar.Size
  92.     local Prev_Size4 = partleftfarfar.Size
  93.     local Prev_Size5 = partleftfarfarfar.Size
  94.     partmiddle.Size = partmiddle.Size:Lerp(Vector3.new(.3,Sound.PlaybackLoudness/100,.3),Settings.MusicLerp)
  95.     wait()
  96.     partleft.Size = partleft.Size:Lerp(Prev_Size,Settings.MusicLerp)
  97.     partright.Size = partright.Size:Lerp(Prev_Size,Settings.MusicLerp)
  98.     partleft.BrickColor = Color
  99.     partright.BrickColor = Color
  100.     wait()
  101.     partleftfar.Size = partleftfar.Size:Lerp(Prev_Size2,Settings.MusicLerp)
  102.     partrightfar.Size = partrightfar.Size:Lerp(Prev_Size2,Settings.MusicLerp)
  103.     partleftfar.BrickColor = Color_2
  104.     partrightfar.BrickColor = Color_2
  105.     wait()
  106.     partleftfarfar.Size = partleftfarfar.Size:Lerp(Prev_Size3,Settings.MusicLerp)
  107.     partrightfarfar.Size = partrightfarfar.Size:Lerp(Prev_Size3,Settings.MusicLerp)
  108.     partleftfarfar.BrickColor = Color_3
  109.     partrightfarfar.BrickColor = Color_3
  110.     wait()
  111.     partleftfarfarfar.Size = partleftfarfarfar.Size:Lerp(Prev_Size4,Settings.MusicLerp)
  112.     partrightfarfarfar.Size = partrightfarfarfar.Size:Lerp(Prev_Size4,Settings.MusicLerp)
  113.     partleftfarfarfar.BrickColor = Color_4
  114.     partrightfarfarfar.BrickColor = Color_4
  115.     wait()
  116.     partleftfarest.Size = partleftfarest.Size:Lerp(Prev_Size5,Settings.MusicLerp)
  117.     partrightfarest.Size = partleftfarest.Size:Lerp(Prev_Size5,Settings.MusicLerp)
  118.     partleftfarest.BrickColor = Color_5
  119.     partrightfarest.BrickColor = Color_5
  120. end)
  121.  
  122. Chatted = player.Chatted:connect(function(msg)
  123.     if msg:lower():sub(1,#Settings.Prefix+#'play ')==Settings.Prefix..'play ' then
  124.         if not partmiddle:FindFirstChild('Sound') then SpawnMusic() end
  125.         local Sound = partmiddle:FindFirstChild('Sound')
  126.         Sound:Stop()
  127.         Sound.SoundId = "http://www.roblox.com/asset?id="..tonumber(msg:sub(#Settings.Prefix+#'play '+1))
  128.         Sound:Play()
  129.     end
  130.     if msg:lower():sub(1,#Settings.Prefix+#'stop')==Settings.Prefix..'stop' then
  131.         local Sound = partmiddle:FindFirstChild('Sound')
  132.         if Sound and Sound.Playing then Sound:Stop() end
  133.     end
  134.     if msg:lower():sub(1,#Settings.Prefix+#'vol ')==Settings.Prefix..'vol ' then
  135.         local Sound = partmiddle:FindFirstChild('Sound')
  136.         if Sound then
  137.             Sound.Volume = tonumber(msg:sub(#Settings.Prefix+#'vol '+1))
  138.         end
  139.         print('Volume: '..tonumber(msg:sub(#Settings.Prefix+#'vol '+1)))
  140.     end
  141.     if msg:lower():sub(1,#Settings.Prefix+#'height ')==Settings.Prefix..'height ' then
  142.         Settings.Height = tonumber(msg:sub(#Settings.Prefix+#'height '+1))
  143.         print('Height: '..tonumber(msg:sub(#Settings.Prefix+#'height '+1)))
  144.     end
  145.     if msg:lower():sub(1,#Settings.Prefix+#'space ')==Settings.Prefix..'space ' then
  146.         Settings.Distance = tonumber(msg:sub(#Settings.Prefix+#'space '+1))
  147.         print("Space: "..tonumber(msg:sub(#Settings.Prefix+#'space '+1)))
  148.     end
  149.     if msg:lower():sub(1,#Settings.Prefix+#'range ')==Settings.Prefix..'range ' then
  150.         Settings.Range = tonumber(msg:sub(#Settings.Prefix+#'range '+1))
  151.         local Sound = partmiddle:FindFirstChild('Sound')
  152.         if Sound then
  153.             Sound.EmitterSize = tonumber(msg:sub(#Settings.Prefix+#'range '+1))
  154.         end
  155.         print('Range: '..tonumber(msg:sub(#Settings.Prefix+#'range '+1)))
  156.     end
  157.     if msg:lower():sub(1,#Settings.Prefix+#'smooth ')==Settings.Prefix..'smooth ' then
  158.         Settings.LerpSpeed = tonumber(msg:sub(#Settings.Prefix+#'smooth '+1))
  159.         print('Smooth: '..tonumber(msg:sub(#Settings.Prefix+#'smooth '+1)))
  160.     end
  161.     if msg:lower():sub(1,#Settings.Prefix+#'mbounce ')==Settings.Prefix..'mbounce ' then
  162.         Settings.MusicLerp = tonumber(msg:sub(#Settings.Prefix+#'mbounce '+1))
  163.         print('Music Bounce: '..tonumber(msg:sub(#Settings.Prefix+#'mbounce '+1)))
  164.     end
  165.     if msg:lower():sub(1,#Settings.Prefix+#'rmv')==Settings.Prefix..'rmv' then
  166.         active = false
  167.         partmiddle:Destroy()
  168.         Chatted:disconnect()
  169.         print("Removed MusicBars")
  170.         script:Destroy()
  171.     end
  172. end)
  173.  
  174.  
  175. print("Music Bars Loaded")
  176. print("Created By: WaverlyCole")
  177. print("Say 'play [ID] to play a song.")
  178. print("Say 'stop' to stop a song.")
  179. print("Say 'vol [#]' to change the volume.")
  180. print("Say 'smooth [#0-1]' to change the follow speed.")
  181. print("Say 'mbounce [#0-1] to change the music bounce.'")
  182. print("Say 'range [#]' to change the music range.")
  183. print("Say 'rmv' to remove all functions.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement