Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BillboardGui0 = Instance.new("BillboardGui")
- TextLabel1 = Instance.new("TextBox")
- TextLabel2 = Instance.new("TextBox")
- BillboardGui0.Name = "gui"
- BillboardGui0.Parent = script
- BillboardGui0.LightInfluence = 1
- BillboardGui0.Size = UDim2.new(20, 0, 10, 0)
- BillboardGui0.Active = true
- BillboardGui0.ClipsDescendants = true
- BillboardGui0.AlwaysOnTop = true
- BillboardGui0.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- BillboardGui0.SizeOffset = Vector2.new(0, 0.5)
- BillboardGui0.StudsOffset = Vector3.new(0, 1, 0)
- TextLabel1.Name = "title"
- TextLabel1.Parent = BillboardGui0
- TextLabel1.Size = UDim2.new(1, 0, 0.100000001, 0)
- TextLabel1.BackgroundColor = BrickColor.new("Black")
- TextLabel1.BackgroundColor3 = Color3.new(0.152941, 0.152941, 0.152941)
- TextLabel1.Font = Enum.Font.Arial
- TextLabel1.FontSize = Enum.FontSize.Size14
- TextLabel1.Text = "Text Visualiser"
- TextLabel1.TextColor = BrickColor.new("Institutional white")
- TextLabel1.TextColor3 = Color3.new(1, 1, 1)
- TextLabel1.TextScaled = true
- TextLabel1.TextSize = 14
- TextLabel1.TextStrokeTransparency = 0
- TextLabel1.TextWrap = true
- TextLabel1.TextWrapped = true
- TextLabel2.Name = "vis"
- TextLabel2.Parent = BillboardGui0
- TextLabel2.Position = UDim2.new(0, 0, 0.100000001, 0)
- TextLabel2.Size = UDim2.new(1, 0, 0.899999976, 0)
- TextLabel2.BackgroundColor = BrickColor.new("Really black")
- TextLabel2.BackgroundColor3 = Color3.new(0, 0, 0)
- TextLabel2.BorderSizePixel = 0
- TextLabel2.Font = Enum.Font.Arial
- TextLabel2.FontSize = Enum.FontSize.Size24
- TextLabel2.Text = ''
- TextLabel2.TextColor = BrickColor.new("Institutional white")
- TextLabel2.TextColor3 = Color3.new(1, 1, 1)
- TextLabel2.TextScaled = true
- TextLabel2.TextSize = 24
- TextLabel2.TextWrap = true
- TextLabel2.TextWrapped = true
- TextLabel2.TextYAlignment = Enum.TextYAlignment.Bottom
- local gui = BillboardGui0
- local vis = gui.vis
- local music = nil
- local plr = owner
- local char,head
- local loud = 0
- local playing = false
- local speed = 1
- local saved_pos = 0
- local vol = 0.5
- local looped = true
- local id = ''
- local st = os.clock()
- local last_vols = {}
- local avgs = {}
- local avg = 0
- local max_avg = 100
- local div = 10
- local bars = 15
- function update_average_loud()
- if loud > 25 then else return end
- avgs[#avgs+1] = loud
- local m = nil
- if #avgs >= max_avg then
- avgs[1] = nil
- m = 1
- end
- local n = 0
- for i,v in pairs(avgs) do
- if m and i > 1 then
- avgs[i-1] = v
- avgs[i] = nil
- end
- n += v
- end
- n = n/#avgs
- avg = n
- end
- local scroll = 5 -- >=1
- function get_bar()
- local vols = {}
- for i = bars,1,-1 do
- local int = loud/(avg+400)
- local t = os.clock()-st
- local min_size = 0
- local max_size = div
- local add_size = max_size-min_size
- add_size = math.clamp(add_size*int,min_size,max_size)
- local ad2 = 5*int*math.abs(math.cos(i/15+t*5))
- ad2 = math.clamp(ad2,0,5)
- vols[i] = math.floor(add_size+ad2)
- --[[
- local max = 500
- local n = 100
- local multi = math.random(0,n)/n
- vols[i] = math.floor(loud/max*div*multi)
- ]]
- end
- return vols
- end
- function gen_text(loud)
- local vols = get_bar(loud)
- last_vols = vols
- local txt = ''
- for y = div,0,-1 do
- for x = 1,bars do
- vols[x] = vols[x] or 0
- if vols[x] > y then
- txt = txt .. '||'
- elseif y == vols[x] then
- txt = txt .. '_'
- else
- txt = txt .. string.rep(' ',2)
- end
- txt = txt .. ' '
- end
- txt = txt .. '\n'
- end
- vis.Text = txt
- end
- local cmds = {}
- local cmd = {}
- function cmd.add(name,func)
- cmds[name] = func
- end
- cmd.add('play',function(i)
- playing = true
- if music then
- music.TimePosition = 0
- end
- saved_pos = 0
- id = i
- end)
- cmd.add('speed',function(s)
- speed = s
- end)
- cmd.add('pos',function(p)
- if music then
- music.TimePosition = p
- end
- saved_pos = p
- end)
- cmd.add('vol',function(v)
- vol = v
- end)
- cmd.add('resume',function()
- playing = true
- end)
- cmd.add('pause',function()
- playing = false
- end)
- cmd.add('stop',function()
- playing = false
- if music then
- music.TimePosition = 0
- end
- saved_pos = 0
- end)
- function cmd.run(id,...)
- if id and cmds[id] then
- local t = ...
- pcall(function()
- cmds[id](t)
- end)
- end
- end
- plr.Chatted:Connect(function(msg)
- if string.sub(msg,1,3) == '/e ' then
- msg = string.sub(msg,4)
- end
- local id = string.split(msg,'/')[1]
- if id then
- local args = string.split(string.sub(msg,string.len(id)+2),'/')
- cmd.run(id,unpack(args))
- end
- end)
- local remote = Instance.new("RemoteEvent")
- remote.Parent = plr['PlayerGui']
- remote.OnServerEvent:Connect(function(lplr,l)
- if plr == lplr then
- loud = l
- end
- end)
- local oval = Instance.new("ObjectValue")
- oval.Name = 'objval'
- oval.Value = music
- oval.Parent = remote
- local ls = NLS([[
- local remote = script.Parent
- local oval = remote:WaitForChild('objval')
- local music = oval.Value
- while wait(0.1) do
- if not music or not music.Parent then
- repeat wait() until oval.Value
- music = oval.Value
- end
- if music and music.Parent then
- remote:FireServer(music.PlaybackLoudness)
- end
- end
- ]],remote)
- function get_char()
- if char and char.Parent and head and head.Parent then else
- repeat wait() until plr.Character
- char = plr.Character
- if char then
- head = char:FindFirstChild('Head')
- end
- if char and head then else
- get_char()
- end
- end
- end
- coroutine.wrap(function()
- while true do
- get_char()
- if gui and head then
- gui.Adornee = head
- end
- if not music or not music.Parent then
- music = Instance.new("Sound")
- music.Looped = looped
- music.TimePosition = saved_pos
- music.Parent = head
- end
- if music then
- saved_pos = music.TimePosition
- oval.Value = music
- music.Name = 'text music'
- music.SoundId = 'rbxassetid://' .. id
- music.Volume = vol
- music.PlaybackSpeed = speed
- music.Parent = head
- if playing then
- music:Resume()
- else
- music:Pause()
- end
- update_average_loud()
- gen_text()
- end
- task.wait()
- end
- end)()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement