Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Written by 12GaugeNick
- -- 12/10/2017
- -- Yeah I kinda got bored and made whatever the fuck this thing is
- -- Fully unoptimizied, but it works. Idc.. killed the bored state i was in
- local create = function(a,b)
- local ins = Instance.new(a)
- for i,v in next,b do
- ins[i] = v
- end
- return ins
- end
- -----------------
- -----------------
- -----------------
- local players = game:GetService("Players")
- local runService = game:GetService("RunService")
- local camera = workspace.CurrentCamera
- local player = players.LocalPlayer
- local sound = Instance.new('Sound', workspace)
- local freq = 0
- local trans = 0
- local avg = 0
- local speed = 0
- local sindex = 0
- local max_dots = 15
- local mutliplier = 5
- local width = 150
- local height = 150
- local pi = math.pi
- local random = math.random
- local min = math.min
- local abs = math.abs
- local default_pos = CFrame.new(-height/2,-10,-(width*1.5))
- local skip = false
- local dots = {}
- local avg_tbl = {}
- local dot_pos = {}
- local sound_ids = {
- 1067739984,
- 657338681,
- 173125494,
- 208566959,
- 189553619,
- 212377911,
- 172511451,
- 182098010
- }
- local ball = create("Part",{BrickColor=BrickColor.White(),Material='Neon',Transparency=.5,Anchored=true,CanCollide=false,Locked=true,Size=Vector3.new(.2,.2,.2),Parent=workspace})
- create("SpecialMesh",{MeshType='Sphere',Scale=Vector3.new(10,10,10),Parent=ball})
- create("Part",{BrickColor=BrickColor.White(),Material='Neon',Transparency=.5,Anchored=true,CanCollide=false,Locked=true,Size=Vector3.new(.2,.2,.2),Name="MidLine",Parent=ball})
- -----------------
- -----------------
- -----------------
- sound.Volume = 1
- spawn(function()
- while true do
- local net_skip = false
- skip = false
- sindex = (sindex + 1)
- if sindex > #sound_ids then
- sindex = 1
- end
- ---
- local aid = sound_ids[sindex]
- sound.SoundId = "rbxassetid://"..tostring(aid)
- sound.TimePosition = 0
- delay(5,function() net_skip=true end)
- repeat wait() until (sound.IsLoaded==true or net_skip==true)
- sound:Play()
- for i = 1,sound.TimeLength do
- if skip then
- break
- end
- wait(1)
- end
- sound:Stop()
- end
- end)
- player.Chatted:connect(function(m)
- m = m:lower()
- if m:sub(0,3) == "/e " then
- m = m:sub(4)
- end
- if m:sub(0,4) == "skip" then
- skip = true
- elseif m:sub(0,3) == "add" then
- local id = m:sub(5)
- if #id >= 3 then
- sindex = #sound_ids
- table.insert(sound_ids, tonumber(id))
- skip = true
- end
- end
- end)
- script.Parent = nil
- -----------------
- -----------------
- -----------------
- local getPosition = function()
- return default_pos*CFrame.new(
- random()*( width - width / 10 ) + width / 20,
- random()*( height - height / 10 ) + height / 20,
- random()*( height - width / 10 ) + height + width / 20 -- /40
- )
- end
- local getMagnitude = function(o1,o2)
- return (o1.Position - o2.Position).magnitude
- end
- local setSpeed = function(freq)
- speed = (freq/500)/120
- end
- local function CLerp(p1,p2,percent)
- local p1x,p1y,p1z,p1R00,p1R01,p1R02,p1R10,p1R11,p1R12,p1R20,p1R21,p1R22 = p1:components()
- local p2x,p2y,p2z,p2R00,p2R01,p2R02,p2R10,p2R11,p2R12,p2R20,p2R21,p2R22 = p2:components()
- return CFrame.new(p1x+percent*(p2x-p1x), p1y+percent*(p2y-p1y) ,p1z+percent*(p2z-p1z),
- (p1R00+percent*(p2R00-p1R00)), (p1R01+percent*(p2R01-p1R01)) ,(p1R02+percent*(p2R02-p1R02)),
- (p1R10+percent*(p2R10-p1R10)), (p1R11+percent*(p2R11-p1R11)) , (p1R12+percent*(p2R12-p1R12)),
- (p1R20+percent*(p2R20-p1R20)), (p1R21+percent*(p2R21-p1R21)) ,(p1R22+percent*(p2R22-p1R22)))
- end
- -----------------
- -----------------
- -----------------
- sound.Ended:connect(function()
- avg = 0
- avg_tbl = {}
- end)
- for num = 1,max_dots do
- local part = ball:Clone()
- part.CFrame = getPosition()
- part.Parent = workspace.CurrentCamera
- table.insert(dots, part)
- end
- -----------------
- -----------------
- -----------------
- runService.RenderStepped:connect(function()
- freq = min(sound.PlaybackLoudness, 500)
- for i,v in next,dots do
- if dot_pos[i] ~= nil then
- v.CFrame = CLerp(v.CFrame, dot_pos[i], speed)
- end
- end
- if freq >= 220 then
- local ran = random(1, max_dots)
- if dot_pos[ran] ~= nil then
- dot_pos[ran] = getPosition()
- else
- table.insert(dot_pos, getPosition())
- end
- end
- end)
- runService.RenderStepped:connect(function()
- for i,basePart in next,dots do
- if dots[i+1] ~= nil then
- local dist = getMagnitude(basePart, dots[i+1])
- basePart.MidLine.Size = Vector3.new(.2,dist,.2)
- basePart.MidLine.CFrame = CFrame.new(basePart.Position, dots[i+1].Position)*CFrame.new(0,0,-dist/2)*CFrame.Angles(pi/2,0,0)
- basePart.MidLine.Transparency = trans
- end
- end
- end)
- while wait() do
- setSpeed(freq)
- if ((freq/200)-1) >= 1 then
- trans = .7
- else
- trans = ((freq/200)-1)
- end
- for _,v in next,dots do
- spawn(function()
- v.Mesh.Scale = Vector3.new(freq/5, freq/5, freq/5)
- v.Transparency = trans
- end)
- end
- if freq >= 210 and freq >= avg then
- local clr = Color3.new(abs(freq/255)-random(0,255),abs(freq/255)-random(0,255),abs(freq/255)-random(0,255))
- for _,v in next,dots do
- v.Color = clr
- end
- if #avg_tbl >= 200 then
- avg_tbl = {}
- end
- local _avg = 0
- table.insert(avg_tbl, freq)
- for _,v in next,avg_tbl do
- _avg = (_avg + v)
- end
- avg = (_avg / #avg_tbl)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement