Advertisement
TheYoutuber_Pro

visualizer test

Apr 16th, 2022 (edited)
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. --[[
  2. name: simple-visualizer
  3. author: Aldanium/recursion/Fernando Goncalves
  4. ]]--
  5.  
  6.  
  7.  
  8.  
  9. local table = {}
  10. local rotation = 0
  11. local playback = 0
  12.  
  13. local character = owner.Character
  14. local rootPart = character['HumanoidRootPart']
  15.  
  16. local new = function(obj, ...)
  17. local Object = Instance.new(obj)
  18. for i,v in pairs(...) do
  19. Object[i] = v
  20. end
  21. return Object
  22. end
  23.  
  24. local tween = function(i, t, p)
  25. game:GetService("TweenService"):Create(i, t, p):Play()
  26. end
  27.  
  28. local visualizer = new("Part", {
  29. Parent = script,
  30. CanCollide = false,
  31. Anchored = true,
  32. Material = "Neon",
  33. Name = "visualizer",
  34. Locked = true
  35. })
  36.  
  37. local music = new("Sound", {
  38. Parent = rootPart,
  39. SoundId = "rbxassetid://247353474",
  40. Name = "music",
  41. Playing = true,
  42. Looped = true
  43. })
  44.  
  45. local remote = new("RemoteEvent", {Name = "remoteEvent", Parent = character})
  46.  
  47. NLS([[
  48. local remote = script.Parent['remoteEvent']
  49. local sound = script.Parent['HumanoidRootPart'].music
  50. game:GetService("RunService").RenderStepped:Connect(function()
  51. remote:FireServer(sound.PlaybackLoudness)
  52. end)
  53. ]], character)
  54.  
  55. remote.OnServerEvent:Connect(function(player, playback)
  56. newPlayback = playback
  57. end)
  58.  
  59. game:GetService("RunService").Heartbeat:Connect(function()
  60. pcall(function()
  61. playback = math.floor(newPlayback)
  62. end)
  63. rotation = rotation + 0.5
  64.  
  65. table.Size = Vector3.new(0.5 + playback/200, 2 + playback/300, 0.5 + playback/200)
  66. table.Color = Color3.fromHSV(tick()/3.25 % 1, 0.66, playback/1000)
  67. table.CFrame = rootPart.CFrame * CFrame.new(0, 0, -5) * CFrame.Angles(math.rad(rotation), 0, math.rad(rotation))
  68.  
  69. tween(visualizer, TweenInfo.new(0.25, Enum.EasingStyle.Sine), table)
  70. end)
  71.  
  72. owner.Chatted:Connect(function(msg)
  73. if msg:sub(1, 5) == "play " then
  74. local soundid = msg:sub(6)
  75.  
  76. music:Stop()
  77. wait()
  78. music.SoundId = "rbxassetid://"..soundid
  79. music:Play()
  80. elseif msg == "stop" then
  81. music:Stop()
  82. end
  83. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement