Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Made by PPATTA/Cass/Inkyy/lynks - I name change alot ---
- -- 299530855
- -- [[ CONFIG ]] --
- local Color1 = Color3.fromRGB(178, 76, 255)
- local Color2 = Color3.fromRGB(255, 76, 178)
- local PI = math.pi
- local HALF_PI = PI * 0.5
- local TAU = PI * 2
- local PREFIX = "!"
- -- 574538568
- local RING = {
- SECTIONS = 25,
- RADIUS = 5,
- AMPLITUDE = 2
- }
- -- 574538568
- -- [[ CONSTANTS ]] --
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local Player = Players.LocalPlayer
- local Color = Color3.new(1,1,1)
- -- [[ UTIL ]] --
- local function NewInstance(class, parent, properties)
- local hasParent = true
- if (not properties) then
- properties = parent
- hasParent = false
- end
- local Instance = Instance.new(class, hasParent and parent)
- if (not properties) then return Instance end
- for property, value in pairs(properties) do
- Instance[property] = value
- end
- return Instance
- end
- local function rand(min, max)
- return (min + (math.random() * (max - min)))
- end
- -- [[ VISUALIZER ]] --
- local Cache = {}
- local CacheMetatable = {__index = Cache}
- function Cache:new(size)
- local self = setmetatable({}, CacheMetatable)
- self.Size = size
- self.Table = {}
- return self
- end
- function Cache:push(value)
- table.insert(self.Table, value)
- if (#self.Table > self.Size) then table.remove(self.Table, 1) end
- end
- function Cache:get(i)
- return self.Table[i]
- end
- local RingSection = {}
- local RingSectionMetatable = {__index = RingSection}
- function RingSection:new(Ring, id)
- local self = setmetatable({}, RingSectionMetatable)
- self.Ring = Ring
- self.ID = id
- self.Part = NewInstance("Part", Ring.Container, {
- Name = string.format("%x", id),
- Size = Vector3.new((TAU / RING.SECTIONS) * RING.RADIUS, 0.25, 0.25),
- CFrame = Ring.Position,
- Anchored = true,
- CanCollide = false,
- Material = Enum.Material.Neon,
- BrickColor = BrickColor.new(Color.r,Color.b,Color.g),
- TopSurface = Enum.SurfaceType.SmoothNoOutlines,
- BottomSurface = Enum.SurfaceType.SmoothNoOutlines
- })
- self.Transparency = 1
- return self
- end
- function RingSection:SetOffset(cframe)
- self.Part.CFrame = self.Ring.Position * cframe
- end
- function RingSection:Render()
- local Part = self.Part
- local Ring = self.Ring
- local Center = Ring.Position.p
- local sections = RING.SECTIONS
- local aint = (TAU / sections)
- local radius = RING.RADIUS
- local yrange = RING.AMPLITUDE
- local id1 = self.ID
- local id2 = id1 + 1
- if (id2 > sections) then id2 = id2 - sections end
- local volume1 = (self.Ring.VolumeCache:get(id1) or 0) * 0.0025
- local volume2 = (self.Ring.VolumeCache:get(id2) or 0) * 0.0025
- local theta1 = aint * id1
- local theta2 = aint * id2
- local seedmult = 1000000
- local y1 = Ring.HeightDict[id1]
- local y2 = Ring.HeightDict[id2]
- local radius1 = radius + math.pow(volume1, 2)
- local radius2 = radius + math.pow(volume2, 2)
- local position1 = Vector3.new(math.cos(theta1) * radius1, y1, math.sin(theta1) * radius1)
- local position2 = Vector3.new(math.cos(theta2) * radius2, y2, math.sin(theta2) * radius2)
- local distance = (position1 - position2).magnitude
- local position = CFrame.new(position1, position2) * CFrame.new(0, 0, -distance * 0.5)
- Part.Transparency = self.Transparency
- Part.Size = Vector3.new(0.25, 0.25, distance)
- self:SetOffset(position)
- end
- local LightningRing = {}
- local LightningRingMetatable = {__index = LightningRing}
- function LightningRing:new(Visualizer)
- local self = setmetatable({}, LightningRingMetatable)
- self.Visualizer = Visualizer
- self.Container = NewInstance("Model", Player.Character, {
- Name = "RingVisualizer"
- })
- self.Speed = 0
- self.Amplitude = 0
- self.Frames = 0
- self.Seed = math.random()
- self.Offset = CFrame.new(0, 0, 0)
- self:UpdatePosition()
- self.Sections = {}
- self.Ghosts = {}
- self.HeightDict = {}
- self.VolumeCache = Cache:new(RING.SECTIONS)
- self.TargetTransparency = {
- init = 0,
- stopping = 1
- }
- return self
- end
- function LightningRing:Init()
- for i = 1, RING.SECTIONS do
- self.Sections[i] = RingSection:new(self, i)
- end
- end
- function LightningRing:GetCFrame()
- return Player.Character.HumanoidRootPart.CFrame * self.Offset
- end
- function LightningRing:UpdatePosition()
- local cf = self:GetCFrame()
- self.CFrame = cf
- self.Position = CFrame.new(cf.p)
- end
- function LightningRing:UpdateHeightDict()
- self.HeightDict = {}
- for i = 1, RING.SECTIONS do
- self.HeightDict[i] = (math.noise(self.Seed, (tick() * self.Speed) % 60, i) + 0.5) * self.Amplitude * RING.AMPLITUDE
- end
- end
- function LightningRing:Render()
- self.Frames = self.Frames + 1
- if (self.Visualizer.State == "playing") then
- local PlaybackLoudness = self.Visualizer.Sound.PlaybackLoudness
- self.Speed = PlaybackLoudness * 0.005
- self.Amplitude = PlaybackLoudness * 0.0025
- self.VolumeCache:push(PlaybackLoudness)
- self.VolumeCache:push(PlaybackLoudness)
- self.Offset = CFrame.new(0, PlaybackLoudness * 0.0025, 0)
- elseif (self.Visualizer.State == "stopping") then
- self.Speed = 0
- self.Amplitude = 0
- self.VolumeCache:push(0)
- end
- self:UpdatePosition()
- self:UpdateHeightDict()
- for _, Ghost in pairs(self.Ghosts) do
- Ghost.Transparency = math.min(1, Ghost.Transparency + 0.05)
- if (Ghost.Transparency == 1) then Ghost:Destroy() end
- end
- for _, Section in pairs(self.Sections) do
- local targetTransparency = self.TargetTransparency[self.Visualizer.State]
- if (targetTransparency and Section.Transparency ~= targetTransparency) then
- Section.Transparency = math.max(0, math.min(1, Section.Transparency + ((targetTransparency - Section.Transparency) * math.random() * 0.1)))
- end
- Section:Render()
- if (self.Visualizer.State == "playing" and (self.Frames % 5 == 0)) then
- local Ghost = Section.Part:Clone()
- Ghost.Parent = self.Container
- Ghost.Transparency = 0.5
- table.insert(self.Ghosts, Ghost)
- end
- end
- end
- function LightningRing:Destroy()
- self.Container:Destroy()
- end
- local Visualizer = {}
- local VisualizerMetatable = {__index = Visualizer}
- function Visualizer:new(options)
- local self = setmetatable({}, VisualizerMetatable)
- self.SoundID = soundID
- self.State = "init"
- self.Ring = LightningRing:new(self)
- self.Sound = NewInstance("Sound", Player.Character.HumanoidRootPart, options)
- self.EndedListener = self.Sound.Ended:connect(function()
- self:Stop()
- end)
- return self
- end
- function Visualizer:Init()
- self.Ring:Init()
- delay(2, function()
- self:Start()
- end)
- self.Heartbeat = RunService.Heartbeat:connect(function()
- self:Render()
- end)
- end
- function Visualizer:Start()
- self.State = "playing"
- self.Sound:Play()
- end
- function Visualizer:Stop()
- self.State = "stopping"
- self.Sound:Stop()
- wait(2)
- self:Destroy()
- end
- function Visualizer:Destroy()
- self.State = "destroyed"
- self.Sound:Destroy()
- self.Ring:Destroy()
- self.EndedListener:disconnect()
- self.Heartbeat:disconnect()
- end
- function Visualizer:Render()
- self.Ring:Render()
- end
- -- [[ COMMANDS ]] --
- local visualizer
- local playbackVolume = 2
- local playbackSpeed = 1
- local Commands = {}
- function Commands.play(args)
- local soundID = args[1]
- local option = args[2]
- if (visualizer) then visualizer:Stop() end
- local options = {
- SoundId = "rbxassetid://" .. soundID,
- Volume = playbackVolume,
- PlaybackSpeed = playbackSpeed
- }
- if (option == "-l") then
- options.Looped = true
- end
- visualizer = Visualizer:new(options)
- visualizer:Init()
- end
- function Commands.stop()
- if (visualizer) then visualizer:Stop() end
- end
- function Commands.audiovolume(args)
- local volume = tonumber(args[1])
- playbackVolume = volume
- if (visualizer) then visualizer.Sound.Volume = playbackVolume end
- end
- function Commands.color1(args)
- Color1 = Color3.fromRGB(args[1],args[2],args[3])
- print(Color1.r,Color1.g,Color1.b)
- end
- function Commands.color2(args)
- Color2 = Color3.fromRGB(args[1],args[2],args[3])
- print(Color2.r,Color2.g,Color2.b)
- end
- function Commands.audiospeed(args)
- local speed = tonumber(args[1])
- playbackSpeed = speed
- if (visualizer) then visualizer.Sound.PlaybackSpeed = playbackSpeed end
- end
- Player.Chatted:connect(function(message)
- if (string.sub(message, 1, 1) ~= PREFIX) then return end
- local rawCommand = string.sub(message, 2)
- local command
- local args = {}
- for carg in rawCommand:gmatch("%S+") do
- if (not command) then
- command = carg
- else
- args[#args + 1] = carg
- end
- end
- local chatCommand = Commands[command]
- if (not chatCommand) then return end
- chatCommand(args)
- end)
- --- 461736208
- while wait(.01) do
- if Player.Character.HumanoidRootPart:FindFirstChild("Sound") then
- s = Player.Character.HumanoidRootPart:FindFirstChild("Sound")
- Color = Color1:lerp(Color2,.2*math.sqrt(math.floor(s.PlaybackLoudness/6)))
- for b,n in pairs(Player.Character.RingVisualizer:GetChildren())do
- n.BrickColor = BrickColor.new(Color.r,Color.g,Color.b)
- end
- end
- end
- -- 299530855
- -- 570351814
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement