PotatoSaiyan

Mountain Visualizer

Mar 8th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. wait(3)
  2. print("Ready")
  3. local Width=2
  4. local Max=100
  5. local MainOwner=game.Players:WaitForChild("RapidOrange")
  6. math.randomseed(tick())
  7. local Commanders={}
  8. local char=MainOwner.Character
  9. local TorsoCF=char.Torso.CFrame
  10. local RandomColor=BrickColor.Blue().Color
  11. spawn(function()
  12. while true do
  13. --RandomColor=BrickColor.Random().Color
  14. RandomColor=BrickColor.Blue().Color
  15. wait(0.2)
  16. end
  17. end)
  18. local parts=Instance.new("Model",workspace.Terrain)
  19. -- Objects
  20.  
  21.  
  22. ----------------------------------------------------------------
  23. local SoundFile=MainOwner.Character.Torso
  24.  
  25. function MakeSound(id,volume,parent)
  26. local Sound=Instance.new("Sound",parent)
  27. Sound.Name="CurrentSong"
  28. Sound.SoundId="rbxassetid://"..id
  29. Sound.Volume=volume
  30. Sound:Play()
  31. Sound.Looped=true
  32. end
  33.  
  34. --build bars
  35.  
  36. function BuildBars()
  37. local amnt=math.abs(Max/Width)
  38. TorsoCF=char.Torso:GetRenderCFrame()
  39. for i = 1,amnt do
  40. SpawnBar(0,(i*Width))
  41. wait()
  42. end
  43. end
  44.  
  45. ------------------
  46.  
  47. function PlayMusic(msg)
  48. if msg:sub(1,5)=="play/" then
  49. if SoundFile:findFirstChild("CurrentSong") then
  50. SoundFile.CurrentSong:Stop()
  51. SoundFile.CurrentSong:Destroy()
  52. spawn(function()
  53. wait(1)
  54. parts:ClearAllChildren()
  55. end)
  56. end
  57. local SoundId=msg:sub(6)
  58. MakeSound(SoundId,10,SoundFile)
  59. BuildBars()
  60. elseif
  61. msg:sub(1,5)=="stop/" then
  62. if SoundFile:findFirstChild("CurrentSong") then
  63. SoundFile.CurrentSong:Stop()
  64. SoundFile.CurrentSong:Destroy()
  65. spawn(function()
  66. wait(1)
  67. parts:ClearAllChildren()
  68. end)
  69. end
  70. end
  71. end
  72.  
  73. function AddPlayers(msg)
  74. if msg:sub(1,4)=="add/" then
  75. local plrName=msg:sub(5)
  76. local player=game.Players:findFirstChild(plrName)
  77. if player then
  78. player.Chatted:connect(PlayMusic)
  79. else
  80. print("Player Not Found")
  81. end
  82. end
  83. end
  84.  
  85. MainOwner.Chatted:connect(PlayMusic)
  86. MainOwner.Chatted:connect(AddPlayers)
  87.  
  88. local VolumeValue=Instance.new("IntValue",script)
  89. VolumeValue.Name="volume"
  90. VolumeValue.Value=0
  91.  
  92. function SpawnBar(Height,x)
  93. local Bar = Instance.new("Part",parts)
  94. Bar.Name = "Bar"
  95. Bar.BrickColor=BrickColor.new(RandomColor)
  96. Bar.Size=Vector3.new(Width,0,Width)
  97. Bar.CFrame=TorsoCF*CFrame.new(x,0,0)
  98. Bar.Anchored=true
  99. Bar.CanCollide=false
  100. Bar.Locked=true
  101. Bar.TopSurface="SmoothNoOutlines"
  102. Bar.BottomSurface="SmoothNoOutlines"
  103. Bar.BackSurface="SmoothNoOutlines"
  104. Bar.FrontSurface="SmoothNoOutlines"
  105. Bar.LeftSurface="SmoothNoOutlines"
  106. Bar.RightSurface="SmoothNoOutlines"
  107. Bar.Material="SmoothPlastic"
  108. --[[spawn(function()
  109. wait(0.1)
  110. Bar:TweenSize(UDim2.new(0,50,0,Height),"Out","Quad",.2,false)
  111. end)]]
  112. --[[spawn(function()
  113. wait(0.1)
  114. Bar:TweenPosition(UDim2.new(0,-70,1,-Height),"Out","Quad",.2,false)
  115. print("Tweened")
  116. end)]]
  117. end
  118.  
  119. function lerp(a, b, t)
  120. return a * (1-t) + (b*t)
  121. end
  122.  
  123.  
  124. spawn(function()
  125. --while true do
  126. game:GetService("RunService").RenderStepped:connect(function()
  127. local CSound=SoundFile:findFirstChild("CurrentSong")
  128. if CSound then
  129. repeat wait()until #parts:GetChildren() == math.abs(Max/Width)
  130. for i,bar in pairs(parts:GetChildren()) do
  131. spawn(function()
  132. local CF=bar.CFrame
  133. if i == math.abs(Max/Width) then
  134. bar.Size=bar.Size:lerp(Vector3.new(Width,math.abs(CSound.PlaybackLoudness/5),30),i/15*CSound.PlaybackLoudness/3000)
  135. else
  136. bar.Size=bar.Size:lerp(Vector3.new(Width,parts:GetChildren()[i+1].Size.Y,30),i/15*CSound.PlaybackLoudness/3000+0.4)
  137. end
  138. bar.CFrame=CF
  139. wait(0.05)
  140. end)
  141. end
  142.  
  143.  
  144.  
  145. end
  146. --wait(.1)
  147. --end
  148. end)
  149. end)
Add Comment
Please, Sign In to add comment