PotatoSaiyan

Ring Visualizer

Mar 8th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1. --- Working 100%
  2. local RunService = game:GetService("RunService")
  3. local Player = game:GetService("Players").LocalPlayer
  4. local Bars = {}
  5. local BarSSizes = {}
  6.  
  7. repeat wait() until Player.Character and Player.Character:FindFirstChild("Torso") -- Error prevention?
  8.  
  9. local Character = Player.Character
  10. local Torso = Character:WaitForChild("Torso")
  11. local Create = LoadLibrary("RbxUtility").Create
  12. local Color = BrickColor.new("Really red")
  13. local Material = "Neon"
  14. local LastPlayBackLoudness = 0
  15. local PlaybackLoudness = 0
  16. local Sound
  17. local AMBars
  18.  
  19. fat = Instance.new("BindableEvent",script)
  20. fat.Name = "Heartbeat"
  21.  
  22. script:WaitForChild("Heartbeat")
  23.  
  24. frame = 1/60
  25. tf = 0
  26. allowframeloss = false --if set to true will fire every frame it possibly can. This will result in multiple events happening at the same time whenever delta returns frame*2 or greater.
  27. tossremainder = false --if set to true t will be set to 0 after Fire()-ing.
  28. lastframe = tick()
  29. script.Heartbeat:Fire() --ayy lmao
  30.  
  31. game:GetService("RunService").Heartbeat:connect(function(s,p) --herp derp
  32. tf = tf + s
  33. if tf >= frame then
  34. if allowframeloss then
  35. script.Heartbeat:Fire()
  36. lastframe=tick()
  37. else
  38. --print("FIRED "..math.floor(t/frame).." FRAME(S)","REMAINDER "..(t - frame*(math.floor(t/frame))))
  39. for i=1, math.floor(tf/frame) do
  40. script.Heartbeat:Fire()
  41. end
  42. lastframe=tick()
  43. end
  44. if tossremainder then
  45. tf = 0
  46. else
  47. tf = tf - frame * math.floor(tf/frame)
  48. end
  49. end
  50. end)
  51.  
  52. for _, Obj in pairs(math) do
  53. getfenv()[_] = Obj
  54. end
  55.  
  56. local BaseCFrame = CFrame.new(0, -3, 0)
  57. local MaxSize = Vector3.new(.5, 8, .1)
  58.  
  59. local function PlaySound(ID,Pitch)
  60. Sound = Create("Sound"){
  61. Parent = Character.Torso,
  62. Pitch = Pitch or 1,
  63. Volume = 1,
  64. Name = math.random(),
  65. MaxDistance = 9e9,
  66. SoundId = "rbxassetid://" .. ID
  67. }
  68. wait()
  69. Sound:Play()
  70. return Sound
  71. end
  72.  
  73. local function NewBar()
  74. local PlaybackLoudness = PlaybackLoudness
  75. local YSize = PlaybackLoudness/1000*MaxSize.Y
  76. Part = Create("Part"){
  77. Parent = Torso,
  78. Size = Vector3.new(MaxSize.X, YSize, MaxSize.Z),
  79. Anchored = true,
  80. CanCollide = false,
  81. BrickColor = Color,
  82. Material = Material,
  83. TopSurface = "SmoothNoOutlines",
  84. BottomSurface = "SmoothNoOutlines",
  85. FrontSurface = "SmoothNoOutlines",
  86. BackSurface = "SmoothNoOutlines",
  87. LeftSurface = "SmoothNoOutlines",
  88. RightSurface = "SmoothNoOutlines",
  89. CFrame = CFrame.new(
  90. (
  91. CFrame.new((Torso.CFrame * BaseCFrame).p)
  92. * CFrame.Angles(0, rad(0), 0)
  93. * CFrame.new(0, YSize, 8)
  94. ).p,
  95. CFrame.new((Torso.CFrame * BaseCFrame * CFrame.new(0, YSize/2, 0)).p).p
  96. )
  97. }
  98.  
  99. --[[Create("SpecialMesh"){
  100. Parent = Part,
  101. Name = "Rbw",
  102. MeshId = "http://www.roblox.com/Asset/?id=9856898",
  103. TextureId = "http://www.roblox.com/asset/?ID=1361097"
  104. }]]
  105.  
  106. local CBarSize = Part.Size
  107. BarSSizes[Part] = CBarSize
  108.  
  109. coroutine.wrap(function()
  110. Part.Size = Vector3.new()
  111. for Index = 1, 10 do
  112. Part.Size = Part.Size:lerp(CBarSize, 1/10*Index)
  113. Part.CFrame = CFrame.new(
  114. (
  115. CFrame.new((Torso.CFrame * BaseCFrame).p)
  116. * CFrame.Angles(0, rad(0), 0)
  117. * CFrame.new(0, Part.Size.Y/2, 8+.1)
  118. ).p,
  119. (Torso.CFrame * BaseCFrame * CFrame.new(0, Part.Size.Y/2, 0)).p
  120. )
  121. RunService.RenderStepped:wait()
  122. end
  123. coroutine.yield()
  124. end)()
  125. Bars[Part] = 0
  126. end
  127.  
  128. local function UpdateFrame()
  129. local part, position = workspace:FindPartOnRay(Ray.new(Torso.CFrame.p, Torso.CFrame.p * Vector3.new(0, -9e9, 0)), Character, false, true)
  130. --print(position.Y)
  131. LastPlayBackLoudness = PlaybackLoudness or 0
  132. PlaybackLoudness = Sound and Sound.PlaybackLoudness or 0
  133. local Bass = (PlaybackLoudness - LastPlayBackLoudness)>100
  134. for Bar, Rotation in pairs(Bars) do
  135. Bars[Bar] = Bars[Bar]+1
  136. local OP = Bar.Parent
  137. --Bar.Rbw.VertexColor = Vector3.new(1/MaxSize.Y*Bar.Size.Y, 0, 0)
  138. Bar.Size = BarSSizes[Bar]:lerp(Vector3.new(MaxSize.X, 0, MaxSize.Z), 1/360*Bars[Bar])
  139. --Bar.Rbw.Scale = Bar.Size*2
  140. Bar.CFrame = CFrame.new(
  141. (
  142. CFrame.new((Torso.CFrame * BaseCFrame).p)
  143. * CFrame.Angles(0, rad(Rotation), 0)
  144. * CFrame.new(0, Bar.Size.Y/2, 8+.1)
  145. ).p,
  146. (Torso.CFrame * BaseCFrame * CFrame.new(0, Bar.Size.Y/2, 0)).p
  147. )
  148. if Bars[Bar] >= 360 then
  149. Bars[Bar] = nil
  150. coroutine.wrap(function()
  151. Bar:Destroy()
  152. coroutine.yield()
  153. end)()
  154. end
  155. end
  156. end
  157.  
  158. local Tick = tick()
  159. local Start
  160.  
  161. Player.Chatted:connect(function(Message)
  162. print(Message)
  163. if Message:lower():sub(1,4) == "stop" then
  164. pcall(function() Sound:stop() end)
  165. elseif Message:lower():sub(1,4) == "play" then
  166. pcall(function() Sound:stop() end)
  167. PlaySound(Message:sub(6))
  168. elseif Message:lower():sub(1,5) == "pitch" then
  169. pcall(function() Sound.Pitch = tonumber(Message:sub(7)) end)
  170. elseif Message:lower():sub(1,3) == "vol" then
  171. pcall(function() Sound.Volume = tonumber(Message:sub(5)) end)
  172. elseif Message:lower():sub(1,6) == "global" then
  173. pcall(function() Sound.Parent = Workspace end)
  174. elseif Message:lower():sub(1,8) == "noglobal" then
  175. pcall(function() Sound.Parent = Character.Torso end)
  176. end
  177. end)
  178.  
  179. coroutine.wrap(function()
  180. while true do
  181. fat.Event:wait()
  182. UpdateFrame()
  183. end
  184. end)()
  185. while true do
  186. for Index = 1, 6 do
  187. fat.Event:wait()
  188. end
  189. NewBar()
  190. end
  191.  
  192. -- Bobby Shmurda - Hot N*gga 168747967
  193. -- Machine Gun Kelly - Merry Go Round 362523942
  194. -- MHD 3 536637576
  195. -- Logic: Nikki 286766819
  196. -- Trae the Truth ft Young Thug Try Me 222630354
  197. -- Young Thug x With Them 401882086
  198.  
  199. --[[
  200. local Frame = 1/30
  201. local RunService = game:GetService("RunService")
  202.  
  203. local function C_Frame()
  204. local Start = tick()
  205. end
  206. ]]
Add Comment
Please, Sign In to add comment