--Orb Visualizer by Joji
script.Parent = workspace
local Music,CurrentLoudness,CurrentSpeed = nil,0,1
do -- Commands
owner.Chatted:Connect(function(msg)
local Segments = string.split(msg, "/")
if Segments[2] ~= nil then
if Segments[1] == "Play" then
if not Music or not Music:IsDescendantOf(workspace) then
Music = Create{
"Sound",
Parent = root,
Volume = 1,
Looped = true
}
else
Music:Stop()
end
local Stats = {
Volume = 1,
PlaybackSpeed = 1,
}
if Segments[2] ~= nil and Segments[2] ~= "" then
Music.SoundId = "rbxassetid://"..Segments[2]
else
Music.SoundId = "rbxassetid://1838780042"
end
if Segments[3] ~= nil and Segments[3] ~= "" then
local Properties = string.split(Segments[3],",")
for _,Property in pairs (Properties)do
local Name,Value = string.match(Property,"(%a+)%s?=%s?(%d+)")
if Stats[Name] ~= nil then
Stats[Name] = Value
end
end
end
for Name,Stat in pairs (Stats) do
Music[Name] = Stat
end
Music:Play()
elseif Segments[1] == "Tune" then
if Music and Music:IsDescendantOf(workspace) then
if Segments[2] ~= nil and Segments[2] ~= "" then
local Stats = {
Volume = 1,
PlaybackSpeed = 1,
}
local Properties = string.split(Segments[2],",")
for _,Property in pairs (Properties)do
local Name,Value = string.match(Property,"(%a+)%s?=%s?(%d+)")
if Stats[Name] ~= nil then
Music[Name] = Value
end
end
end
else
warn("Music not found, please start with Play/ instead.")
end
elseif Segments[1] == "Stop" then
if Music and Music:IsDescendantOf(workspace) then
Music:Stop()
end
end
end
end)
end
do -- NLS
local Localboi
Transponder = Create{
"RemoteFunction",
Name = "Transponder",
Parent = rStorage
}
RunLocal = function()
Localboi = NLS([[repeat wait() until script:FindFirstChild("Transponder")
Transponder = script.Transponder.Value
function Transponder.OnClientInvoke(Music)
return Music.PlaybackLoudness
end]],owner.PlayerGui)
Create{
"ObjectValue",
Parent = Localboi,
Name = "Transponder",
Value = Transponder
}
end
RunLocal()
runs.Stepped:connect(function()
if not Localboi:IsDescendantOf(owner) then
RunLocal()
end
end)
end
do -- Math
runs.Heartbeat:connect(function()
if Music and Music:IsDescendantOf(workspace) then
CurrentLoudness = Transponder:InvokeClient(owner,Music)
CurrentSpeed = Music.PlaybackSpeed
else
CurrentLoudness = 0
CurrentSpeed = 1
end
end)
Rad = math.pi/180
BezierCurve = {}
NumberLerp = function(Start,End,Alpha)
return Start + (End - Start) * Alpha
end
function BezierCurve.CreateCurve(Alpha, Points)
if #Points == 1 then
return Points[1]
else
local TempTable = {}
for Iteration = 1, (#Points-1) do
TempTable[Iteration] = NumberLerp(Points[Iteration],Points[Iteration+1],Alpha)
end
return BezierCurve.CreateCurve(Alpha,TempTable)
end
end
end
do -- Orb
OrbLogic = {
SetTick = tick(),
Adder = 0,
Iteration = 0,
Speed = .4,
CurveDegree = 180,
Distance = 4,
AttachedPart = root,
CurrentlyMoving = true,
}
Orb = {}
Orb.P0 = Vector3.new(math.random(1,360),math.random(1,360),math.random(1,360))
Orb.P3 = Vector3.new(math.random(1,360),math.random(1,360),math.random(1,360))
Orb.P1 = Vector3.new(Orb.P0.X+((math.random(0,1)-.5)*2)*OrbLogic.CurveDegree,Orb.P0.Y+((math.random(0,1)-.5)*2)*OrbLogic.CurveDegree,Orb.P0.Z+((math.random(0,1)-.5)*2)*OrbLogic.CurveDegree)
Orb.P2 = Vector3.new(Orb.P3.X+((math.random(0,1)-.5)*2)*OrbLogic.CurveDegree,Orb.P3.Y+((math.random(0,1)-.5)*2)*OrbLogic.CurveDegree,Orb.P3.Z+((math.random(0,1)-.5)*2)*OrbLogic.CurveDegree)
Orb.Color = HSV(0,1,1)
Orb.Size = Vector3.new(0.5,0.5,0.5)
local PartToAbuse = Create.new{
"Part",
Parent = script,
Shape = Enum.PartType.Ball,
Size = Orb.Size,
Anchored = true,
CanCollide = false,
Material = Enum.Material.Neon,
Color = Orb.Color,
Transparency = 1,
Position = Vector3.new(1*OrbLogic.Distance,0,0),
Surfaces = Enum.SurfaceType.SmoothNoOutlines
}
local Attach1 = Create.new{
"Attachment",
Parent = PartToAbuse,
Position = Vector3.new(0,Orb.Size.Y/2,0),
Name = "Attach1"
}
local Attach2 = Create.new{
"Attachment",
Parent = PartToAbuse,
Position = Vector3.new(0,-Orb.Size.Y/2,0),
Name = "Attach2"
}
local Trail = Create.new{
"Trail",
Parent = PartToAbuse,
Attachment0 = Attach1,
Attachment1 = Attach2,
Color = ColorSequence.new(Orb.Color),
FaceCamera = true,
Transparency = NumberSequence.new(1,1),
Lifetime = 8
}
Orb.Orb = PartToAbuse
Orb.Distance = Vector3.new(1,0,0)
Orb.Transparency = 1
Orb.Active = true
Orb.DamageActive = false
game:GetService("RunService").Stepped:Connect(function()
PartToAbuse.Size = Orb.Size
Attach1.Position = Vector3.new(0,Orb.Size.Y/2,0)
Attach2.Position = Vector3.new(0,-Orb.Size.Y/2,0)
PartToAbuse.Color = Orb.Color
if Trail.Enabled == true then
Trail.Color = ColorSequence.new(Orb.Color)
end
PartToAbuse.Transparency = Orb.Transparency
Trail.Transparency = NumberSequence.new(Orb.Transparency,1)
if OrbLogic.CurrentlyMoving == false then
OrbLogic.SetTick = tick()
end
OrbLogic.Adder = OrbLogic.Adder+((NumberLerp(OrbLogic.SetTick,tick(),OrbLogic.Speed)-OrbLogic.SetTick))
local NewIteration = false
if OrbLogic.Iteration < math.floor(OrbLogic.Adder) then
OrbLogic.Iteration = math.floor(OrbLogic.Adder)
NewIteration = true
end
if NewIteration == true then
Orb.P0 = Orb.P3
Orb.P1 = (Orb.P3-Orb.P2)+Orb.P3
Orb.P3 = Orb.P0+Vector3.new(math.random(1,360),math.random(1,360),math.random(1,360))
Orb.P2 = Vector3.new(Orb.P3.X+((math.random(0,1)-.5)*2)*OrbLogic.CurveDegree,Orb.P3.Y+((math.random(0,1)-.5)*2)*OrbLogic.CurveDegree,Orb.P3.Z+((math.random(0,1)-.5)*2)*OrbLogic.CurveDegree)
end
local Angle = BezierCurve.CreateCurve(OrbLogic.Adder-OrbLogic.Iteration,{Orb.P0,Orb.P1,Orb.P2,Orb.P3})
if Orb.Active == true then
Orb.Orb.CFrame = Orb.Orb.CFrame:Lerp(CFrame.new(OrbLogic.AttachedPart.CFrame.Position)*CFrame.Angles(Angle.X*Rad,Angle.Y*Rad,Angle.Z*Rad)*CFrame.new(OrbLogic.Distance*Orb.Distance.X,OrbLogic.Distance*Orb.Distance.Y,OrbLogic.Distance*Orb.Distance.Z),.45)
end
Orb.Color = HSV((OrbLogic.Adder/3)%1,1,1)
local SizeVal = .5+CurrentLoudness/250
Orb.Size = Vector3.new(SizeVal,SizeVal,SizeVal)
OrbLogic.Speed = .4*CurrentSpeed
OrbLogic.AttachedPart = root
OrbLogic.SetTick = tick()
end)
for x = 100,0,-1 do
WaitHB()
Orb.Transparency = x/50
end
end