KrYn0MoRe

heartbeat graph

Oct 15th, 2021
805
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local mx = 100
  2.  
  3. function cpart(anc,trans)
  4.     local part = Instance.new("Part")
  5.     part.Anchored = anc or true
  6.     part.Transparency = trans or 0
  7.     part.Material = Enum.Material.SmoothPlastic
  8.     part.Parent = script
  9.     return part
  10. end
  11.  
  12. local inc = 1
  13. local offset = Vector3.new(30,mx/2,30)
  14.  
  15. local cords = {}
  16.  
  17. local mon = Instance.new("Sound")
  18.  
  19. for x = 1,mx do
  20.     local t = os.clock()
  21.    
  22.     local cord = cpart(true,0)
  23.     cord.Size = Vector3.new(1,1,1)
  24.     cord.Position = offset+Vector3.new(x,0,0)
  25.    
  26.     if x == 1 then
  27.         mon.SoundId = 'rbxassetid://3929730934'
  28.         mon.Volume = 0.5
  29.         mon.Looped = true
  30.         mon.Parent = cord
  31.         mon:Play()
  32.     end
  33.    
  34.     cords[x] = cord
  35. end
  36.  
  37. while true do
  38.     for x = 1,mx do
  39.         local t = os.clock()
  40.         local max = 10
  41.         local y = 1000*math.pow(50,-1*(1+t%1))+math.sin(max*math.pi*t)
  42.        
  43.         mon.Volume = math.clamp(y/(max*2),0,1)*2
  44.         local beat = cords[x]
  45.         beat.Position = offset+Vector3.new(x,y,0)
  46.         game:GetService("TweenService"):Create(beat,TweenInfo.new(0),{
  47.             Transparency = 0,
  48.         }):Play()
  49.         beat.Transparency = 0
  50.         game:GetService("TweenService"):Create(beat,TweenInfo.new(1),{
  51.             Transparency = 1,
  52.         }):Play()
  53.         game:GetService("RunService").Stepped:Wait()
  54.     end
  55. end
RAW Paste Data