Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Credits:
- fang - For inspiration
- victiny1223 - because I scripted it.
- idk - have fun I guess
- --]]
- lplr = game:GetService('Players').LocalPlayer
- runservice = game:GetService('RunService')
- lcharacter = lplr.Character
- repeat wait() until lcharacter
- lhumpart = lcharacter:FindFirstChild("Torso")
- mode = ("Default")
- visualiserParts = {}
- --[[Commands:
- 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
- mode (Default, Still, Large, Wave) - Changes the audio visualiser mode
- playmusic (MUSICID) - Plays the music/sound with that corresponding asset id
- stopmusic - Stops all music/sounds including your own.
- --]]
- -------------------------------------------------------Default Colors
- colors = {
- {r = 0, g = 0, b = 255},
- {r = 255, g = 0, b = 0}
- }
- ------------------------------------------------------------Circle of Parts
- smoothOut = function(basepart)
- local f = {'Front','Back','Bottom','Top','Left','Right'}
- if basepart:IsA("BasePart") then
- for _, face in ipairs(f) do
- basepart[face .. 'Surface'] = Enum.SurfaceType.Smooth
- end
- end
- end
- --------------------------------------------------------UpdateBlock Function
- updateBlock = function()
- for angle, p in next, visualiserParts do
- p.Parent = lcharacter
- p.CanCollide = false
- p.Material = Enum.Material.Neon
- p.Anchored = true
- if sound then
- volume = sound.PlaybackLoudness
- --Setting the size of part
- ChangeMode(mode, sound.PlaybackLoudness)
- p.Size = Vector3.new(1, volume / bricks[angle], 1)
- --Setting color of part
- color1 = Color3.new(colors[1]['r']/255, colors[1]['g']/255, colors[1]['b']/255)
- color2 = Color3.new(colors[2]['r']/255, colors[2]['g']/255, colors[2]['b']/255)
- if volume <= 475 then
- p.BrickColor = BrickColor.new( color1:Lerp(color2, volume/475) )
- else
- p.BrickColor = BrickColor.new( color2 )
- end
- else
- p.Size = Vector3.new(1, 1, 1)
- end
- --Setting the cframe of part
- p.CFrame = lhumpart.CFrame * CFrame.Angles(0, math.rad(angle), 0)
- * CFrame.new(20, p.Size.Y/2, 0)
- end
- end
- --------------------------------------------------------Setting up visualiser for the first time
- bricks = {}
- lhumpart.Anchored = true
- -- Change mode function
- random = {}
- for i = 1, 360 do
- random[i] = math.random(10, 100)
- end
- ChangeMode = function(str)
- if str == "Wave" then
- for i = 1, 360 do
- bricks[i] = i
- end
- elseif str == "Still" then
- for i = 1, 360 do
- bricks[i] = random[i]
- end
- elseif str == "Large" then
- for i = 1, 360 do
- bricks[i] = sound.PlaybackLoudness
- end
- elseif str == "Default" then
- for i = 1, 360 do
- bricks[i] = math.random(10, 100)
- end
- end
- end
- setupVisualiser = function()
- for angle = 1, 360 do
- if angle % 5 == 0 then
- local p = Instance.new("Part")
- ChangeMode('Default')
- visualiserParts[angle] = p
- smoothOut(p)
- end
- end
- runservice:BindToRenderStep('updateBlock', Enum.RenderPriority.First.Value, function()
- updateBlock()
- end)
- end
- setupVisualiser()
- lhumpart.Anchored = false
- ------------------------------------------------------------Music Function
- sound = nil
- playmusic = function(id)
- if sound then
- sound:Remove()
- sound = nil
- end
- local sound = Instance.new("Sound")
- sound.SoundId = ('rbxassetid://' .. id)
- sound.Volume = 5
- sound.Parent = workspace
- sound:Play()
- return sound
- end
- removeSounds = function(directory)
- for _, obj in pairs(directory:GetChildren()) do
- pcall(function()
- if obj:IsA("Sound") then
- obj:Remove()
- sound = nil
- elseif #obj:GetChildren() > 0 then
- removeSounds(obj)
- end
- end)
- end
- end
- ----------------------------------------------------------Re-adding Visualiser after death
- lplr.CharacterAdded:connect(function()
- runservice:UnbindFromRenderStep('updateBlock')
- lplr = game:GetService('Players').LocalPlayer
- runservice = game:GetService('RunService')
- lcharacter = lplr.Character
- lhumpart = lcharacter:WaitForChild("HumanoidRootPart")
- setupVisualiser()
- end)
- -- FindSound function
- findsound = function()
- for i, v in next, workspace:GetChildren() do
- if v:IsA("Sound") and v ~= sound then
- newsound = v
- end
- if newsound then
- sound = newsound
- end
- end
- end
- --Check message function
- checkMessage = function(inputMsg)
- local cmd = inputMsg:match('(%a+)')
- local arg = inputMsg:match('%a+%s(%w+)')
- local color,r,g,b = inputMsg:match('%a+(%d)%s(%d+)%s(%d+)%s(%d+)')
- if cmd and arg then
- if cmd:lower() == 'playmusic' then
- sound = playmusic(tonumber(arg))
- elseif cmd:lower() == 'mode' then
- mode = arg
- end
- elseif cmd:lower() == 'stopmusic' then
- removeSounds(workspace)
- elseif cmd:lower() == 'syncsound' then
- findsound()
- elseif color and r and g and b then
- color = tonumber(color)
- r = tonumber(r)
- g = tonumber(g)
- b = tonumber(b)
- if colors[color] then
- local c = colors[color]
- c['r'] = r
- c['g'] = g
- c['b'] = b
- end
- end
- end
- lplr.Chatted:connect(checkMessage)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement