Advertisement
Omarxxx4343

Untitled

Jun 17th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.03 KB | None | 0 0
  1. --[[Credits:
  2. fang - For inspiration
  3. victiny1223 - because I scripted it.
  4. idk - have fun I guess
  5. --]]
  6. lplr = game:GetService('Players').LocalPlayer
  7. runservice = game:GetService('RunService')
  8. lcharacter = lplr.Character
  9. repeat wait() until lcharacter
  10. lhumpart = lcharacter:FindFirstChild("Torso")
  11. mode = ("Default")
  12. visualiserParts = {}
  13. --[[Commands:
  14. color(1-3 depending on which color you'd like to change) red green blue - Changes that color to the red green blue code provided
  15. mode (Default, Still, Large, Wave) - Changes the audio visualiser mode
  16. playmusic (MUSICID) - Plays the music/sound with that corresponding asset id
  17. stopmusic - Stops all music/sounds including your own.
  18. --]]
  19. -------------------------------------------------------Default Colors
  20. colors = {
  21. {r = 0, g = 0, b = 255},
  22. {r = 255, g = 0, b = 0}
  23. }
  24. ------------------------------------------------------------Circle of Parts
  25. smoothOut = function(basepart)
  26. local f = {'Front','Back','Bottom','Top','Left','Right'}
  27. if basepart:IsA("BasePart") then
  28. for _, face in ipairs(f) do
  29. basepart[face .. 'Surface'] = Enum.SurfaceType.Smooth
  30. end
  31. end
  32. end
  33. --------------------------------------------------------UpdateBlock Function
  34. updateBlock = function()
  35. for angle, p in next, visualiserParts do
  36. p.Parent = lcharacter
  37. p.CanCollide = false
  38. p.Material = Enum.Material.Neon
  39. p.Anchored = true
  40. if sound then
  41. volume = sound.PlaybackLoudness
  42. --Setting the size of part
  43. ChangeMode(mode, sound.PlaybackLoudness)
  44. p.Size = Vector3.new(1, volume / bricks[angle], 1)
  45. --Setting color of part
  46. color1 = Color3.new(colors[1]['r']/255, colors[1]['g']/255, colors[1]['b']/255)
  47. color2 = Color3.new(colors[2]['r']/255, colors[2]['g']/255, colors[2]['b']/255)
  48. if volume <= 475 then
  49. p.BrickColor = BrickColor.new( color1:Lerp(color2, volume/475) )
  50. else
  51. p.BrickColor = BrickColor.new( color2 )
  52. end
  53. else
  54. p.Size = Vector3.new(1, 1, 1)
  55. end
  56. --Setting the cframe of part
  57. p.CFrame = lhumpart.CFrame * CFrame.Angles(0, math.rad(angle), 0)
  58. * CFrame.new(20, p.Size.Y/2, 0)
  59. end
  60. end
  61. --------------------------------------------------------Setting up visualiser for the first time
  62. bricks = {}
  63. lhumpart.Anchored = true
  64. -- Change mode function
  65. random = {}
  66. for i = 1, 360 do
  67. random[i] = math.random(10, 100)
  68. end
  69. ChangeMode = function(str)
  70. if str == "Wave" then
  71. for i = 1, 360 do
  72. bricks[i] = i
  73. end
  74. elseif str == "Still" then
  75. for i = 1, 360 do
  76. bricks[i] = random[i]
  77. end
  78. elseif str == "Large" then
  79. for i = 1, 360 do
  80. bricks[i] = sound.PlaybackLoudness
  81. end
  82. elseif str == "Default" then
  83. for i = 1, 360 do
  84. bricks[i] = math.random(10, 100)
  85. end
  86. end
  87. end
  88. setupVisualiser = function()
  89. for angle = 1, 360 do
  90. if angle % 5 == 0 then
  91. local p = Instance.new("Part")
  92. ChangeMode('Default')
  93. visualiserParts[angle] = p
  94. smoothOut(p)
  95. end
  96. end
  97. runservice:BindToRenderStep('updateBlock', Enum.RenderPriority.First.Value, function()
  98. updateBlock()
  99. end)
  100. end
  101. setupVisualiser()
  102. lhumpart.Anchored = false
  103. ------------------------------------------------------------Music Function
  104. sound = nil
  105. playmusic = function(id)
  106. if sound then
  107. sound:Remove()
  108. sound = nil
  109. end
  110. local sound = Instance.new("Sound")
  111. sound.SoundId = ('rbxassetid://' .. id)
  112. sound.Volume = 5
  113. sound.Parent = workspace
  114. sound:Play()
  115. return sound
  116. end
  117.  
  118. removeSounds = function(directory)
  119. for _, obj in pairs(directory:GetChildren()) do
  120. pcall(function()
  121. if obj:IsA("Sound") then
  122. obj:Remove()
  123. sound = nil
  124. elseif #obj:GetChildren() > 0 then
  125. removeSounds(obj)
  126. end
  127. end)
  128. end
  129. end
  130. ----------------------------------------------------------Re-adding Visualiser after death
  131. lplr.CharacterAdded:connect(function()
  132. runservice:UnbindFromRenderStep('updateBlock')
  133. lplr = game:GetService('Players').LocalPlayer
  134. runservice = game:GetService('RunService')
  135. lcharacter = lplr.Character
  136. lhumpart = lcharacter:WaitForChild("HumanoidRootPart")
  137. setupVisualiser()
  138. end)
  139. -- FindSound function
  140. findsound = function()
  141. for i, v in next, workspace:GetChildren() do
  142. if v:IsA("Sound") and v ~= sound then
  143. newsound = v
  144. end
  145. if newsound then
  146. sound = newsound
  147. end
  148. end
  149. end
  150. --Check message function
  151. checkMessage = function(inputMsg)
  152. local cmd = inputMsg:match('(%a+)')
  153. local arg = inputMsg:match('%a+%s(%w+)')
  154. local color,r,g,b = inputMsg:match('%a+(%d)%s(%d+)%s(%d+)%s(%d+)')
  155. if cmd and arg then
  156. if cmd:lower() == 'playmusic' then
  157. sound = playmusic(tonumber(arg))
  158. elseif cmd:lower() == 'mode' then
  159. mode = arg
  160. end
  161. elseif cmd:lower() == 'stopmusic' then
  162. removeSounds(workspace)
  163. elseif cmd:lower() == 'syncsound' then
  164. findsound()
  165. elseif color and r and g and b then
  166. color = tonumber(color)
  167. r = tonumber(r)
  168. g = tonumber(g)
  169. b = tonumber(b)
  170. if colors[color] then
  171. local c = colors[color]
  172. c['r'] = r
  173. c['g'] = g
  174. c['b'] = b
  175. end
  176. end
  177. end
  178. lplr.Chatted:connect(checkMessage)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement