Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.31 KB | None | 0 0
  1. -- Written by 12GaugeNick
  2. -- 12/10/2017
  3. -- Yeah I kinda got bored and made whatever the fuck this thing is
  4. -- Fully unoptimizied, but it works. Idc.. killed the bored state i was in
  5.  
  6. local create = function(a,b)
  7. local ins = Instance.new(a)
  8. for i,v in next,b do
  9. ins[i] = v
  10. end
  11. return ins
  12. end
  13.  
  14. -----------------
  15. -----------------
  16. -----------------
  17.  
  18. local players = game:GetService("Players")
  19. local runService = game:GetService("RunService")
  20.  
  21. local camera = workspace.CurrentCamera
  22. local player = players.LocalPlayer
  23. local sound = Instance.new('Sound', workspace)
  24.  
  25. local freq = 0
  26. local trans = 0
  27. local avg = 0
  28. local speed = 0
  29. local sindex = 0
  30. local max_dots = 15
  31. local mutliplier = 5
  32. local width = 150
  33. local height = 150
  34. local pi = math.pi
  35. local random = math.random
  36. local min = math.min
  37. local abs = math.abs
  38.  
  39. local default_pos = CFrame.new(-height/2,-10,-(width*1.5))
  40.  
  41. local skip = false
  42.  
  43. local dots = {}
  44. local avg_tbl = {}
  45. local dot_pos = {}
  46. local sound_ids = {
  47. 1067739984,
  48. 657338681,
  49. 173125494,
  50. 208566959,
  51. 189553619,
  52. 212377911,
  53. 172511451,
  54. 182098010
  55.  
  56. }
  57.  
  58. local ball = create("Part",{BrickColor=BrickColor.White(),Material='Neon',Transparency=.5,Anchored=true,CanCollide=false,Locked=true,Size=Vector3.new(.2,.2,.2),Parent=workspace})
  59. create("SpecialMesh",{MeshType='Sphere',Scale=Vector3.new(10,10,10),Parent=ball})
  60. create("Part",{BrickColor=BrickColor.White(),Material='Neon',Transparency=.5,Anchored=true,CanCollide=false,Locked=true,Size=Vector3.new(.2,.2,.2),Name="MidLine",Parent=ball})
  61.  
  62. -----------------
  63. -----------------
  64. -----------------
  65.  
  66. sound.Volume = 1
  67.  
  68. spawn(function()
  69. while true do
  70. local net_skip = false
  71. skip = false
  72. sindex = (sindex + 1)
  73. if sindex > #sound_ids then
  74. sindex = 1
  75. end
  76. ---
  77. local aid = sound_ids[sindex]
  78. sound.SoundId = "rbxassetid://"..tostring(aid)
  79. sound.TimePosition = 0
  80. delay(5,function() net_skip=true end)
  81. repeat wait() until (sound.IsLoaded==true or net_skip==true)
  82. sound:Play()
  83. for i = 1,sound.TimeLength do
  84. if skip then
  85. break
  86. end
  87. wait(1)
  88. end
  89. sound:Stop()
  90. end
  91. end)
  92.  
  93. player.Chatted:connect(function(m)
  94. m = m:lower()
  95. if m:sub(0,3) == "/e " then
  96. m = m:sub(4)
  97. end
  98. if m:sub(0,4) == "skip" then
  99. skip = true
  100. elseif m:sub(0,3) == "add" then
  101. local id = m:sub(5)
  102. if #id >= 3 then
  103. sindex = #sound_ids
  104. table.insert(sound_ids, tonumber(id))
  105. skip = true
  106. end
  107. end
  108. end)
  109.  
  110. script.Parent = nil
  111.  
  112. -----------------
  113. -----------------
  114. -----------------
  115.  
  116. local getPosition = function()
  117. return default_pos*CFrame.new(
  118. random()*( width - width / 10 ) + width / 20,
  119. random()*( height - height / 10 ) + height / 20,
  120. random()*( height - width / 10 ) + height + width / 20 -- /40
  121. )
  122. end
  123.  
  124. local getMagnitude = function(o1,o2)
  125. return (o1.Position - o2.Position).magnitude
  126. end
  127.  
  128. local setSpeed = function(freq)
  129. speed = (freq/500)/120
  130. end
  131.  
  132. local function CLerp(p1,p2,percent)
  133. local p1x,p1y,p1z,p1R00,p1R01,p1R02,p1R10,p1R11,p1R12,p1R20,p1R21,p1R22 = p1:components()
  134. local p2x,p2y,p2z,p2R00,p2R01,p2R02,p2R10,p2R11,p2R12,p2R20,p2R21,p2R22 = p2:components()
  135. return CFrame.new(p1x+percent*(p2x-p1x), p1y+percent*(p2y-p1y) ,p1z+percent*(p2z-p1z),
  136. (p1R00+percent*(p2R00-p1R00)), (p1R01+percent*(p2R01-p1R01)) ,(p1R02+percent*(p2R02-p1R02)),
  137. (p1R10+percent*(p2R10-p1R10)), (p1R11+percent*(p2R11-p1R11)) , (p1R12+percent*(p2R12-p1R12)),
  138. (p1R20+percent*(p2R20-p1R20)), (p1R21+percent*(p2R21-p1R21)) ,(p1R22+percent*(p2R22-p1R22)))
  139. end
  140.  
  141. -----------------
  142. -----------------
  143. -----------------
  144.  
  145. sound.Ended:connect(function()
  146. avg = 0
  147. avg_tbl = {}
  148. end)
  149.  
  150. for num = 1,max_dots do
  151. local part = ball:Clone()
  152. part.CFrame = getPosition()
  153. part.Parent = workspace.CurrentCamera
  154. table.insert(dots, part)
  155. end
  156.  
  157. -----------------
  158. -----------------
  159. -----------------
  160.  
  161. runService.RenderStepped:connect(function()
  162. freq = min(sound.PlaybackLoudness, 500)
  163. for i,v in next,dots do
  164. if dot_pos[i] ~= nil then
  165. v.CFrame = CLerp(v.CFrame, dot_pos[i], speed)
  166. end
  167. end
  168. if freq >= 220 then
  169. local ran = random(1, max_dots)
  170. if dot_pos[ran] ~= nil then
  171. dot_pos[ran] = getPosition()
  172. else
  173. table.insert(dot_pos, getPosition())
  174. end
  175. end
  176. end)
  177.  
  178. runService.RenderStepped:connect(function()
  179. for i,basePart in next,dots do
  180. if dots[i+1] ~= nil then
  181. local dist = getMagnitude(basePart, dots[i+1])
  182. basePart.MidLine.Size = Vector3.new(.2,dist,.2)
  183. basePart.MidLine.CFrame = CFrame.new(basePart.Position, dots[i+1].Position)*CFrame.new(0,0,-dist/2)*CFrame.Angles(pi/2,0,0)
  184. basePart.MidLine.Transparency = trans
  185. end
  186. end
  187. end)
  188.  
  189. while wait() do
  190. setSpeed(freq)
  191. if ((freq/200)-1) >= 1 then
  192. trans = .7
  193. else
  194. trans = ((freq/200)-1)
  195. end
  196. for _,v in next,dots do
  197. spawn(function()
  198. v.Mesh.Scale = Vector3.new(freq/5, freq/5, freq/5)
  199. v.Transparency = trans
  200. end)
  201. end
  202. if freq >= 210 and freq >= avg then
  203. local clr = Color3.new(abs(freq/255)-random(0,255),abs(freq/255)-random(0,255),abs(freq/255)-random(0,255))
  204. for _,v in next,dots do
  205. v.Color = clr
  206. end
  207. if #avg_tbl >= 200 then
  208. avg_tbl = {}
  209. end
  210. local _avg = 0
  211. table.insert(avg_tbl, freq)
  212. for _,v in next,avg_tbl do
  213. _avg = (_avg + v)
  214. end
  215. avg = (_avg / #avg_tbl)
  216. end
  217. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement