Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --ONLY EDIT WHERE INDICATED BY --<'s AND ONLY WHERE INDICATED BY -->'s IF YOU HAVE EXPERIENCE IN LUA SYNTAX
- --Server-Sided for maximum efficiency
- --@tusKOr661
- --/clearcolors newColor
- --/addcolor newColor
- --/endorb
- wait();
- if(script)then pcall(game.Destroy,script); end;
- --loadstring('\0')();
- module={
- settings={
- colors={'Really red';'Black'};--> Change to make number of colors in secondary trailMode and orb color changing
- owner='tusKOr661';--< Change to your name
- trailMode='default';--<secondary, default
- speed=100;--<default speed -> int between 0 and inf
- };
- data={
- orbInstance=nil;
- lastLocation=CFrame.new(0,10,0);
- lastOwnerLocation=CFrame.new(0,10,0);
- lastColorInt=1;
- };
- functions={
- lockInstance=function(instance)
- local connection;
- connection=instance.ancestryChanged:connect(function()
- pcall(connection.disconnect,connection);
- instance:destroy();
- module.functions.newOrb();
- end);
- end;
- newOrb=function()
- pcall(function() module.data.orbInstance:destroy(); end);
- local orb=Instance.new('Part',workspace);
- orb.Anchored=true;
- orb.Name='ORB\0ORB';
- orb.TopSurface,orb.BottomSurface='Smooth','Smooth';
- orb.Size,orb.Shape=Vector3.new(1,1,1),'Ball';
- orb.Color=BrickColor.new(module.settings.colors[(module.data.lastColorInt%#module.settings.colors)+1]).Color;
- module.functions.lockInstance(orb);
- module.data.orbInstance=orb;
- end;
- mainLoop=function(time)
- module.data.lastColorInt=module.data.lastColorInt+1;
- if(module.data.orbInstance and module.data.orbInstance.Parent)then
- local cframe=module.data.orbInstance.CFrame;
- local distance=(cframe.p-module.data.lastLocation.p).magnitude;
- module.data.orbInstance.Color=BrickColor.new(module.settings.colors[(module.data.lastColorInt%#module.settings.colors)+1]).Color;
- if(distance>0)then
- local trail=Instance.new('Part',module.data.orbInstance);
- trail.Color=module.data.orbInstance.Color;
- trail.Anchored=true;
- trail.CanCollide=false;
- trail.TopSurface='Smooth';
- trail.BottomSurface='Smooth';
- trail.FormFactor='Custom';
- trail.Size=((module.settings.trailMode=='default'and Vector3.new(0,0,distance))or Vector3.new(1,1,1));
- trail.CFrame=((module.settings.trailMode~='default' and CFrame.new(module.data.lastLocation.p,cframe.p)*CFrame.new(0,0,.5)*CFrame.Angles(math.rad(math.random(1,360)),math.rad(math.random(1,360)),math.rad(math.random(1,360))))or(CFrame.new(module.data.lastLocation.p,cframe.p)*CFrame.new(0,0,-distance/2)))
- coroutine.wrap(function()
- local f=trail.CFrame;
- local s=trail.Size;
- game:service'Debris':AddItem(trail,1.5);
- wait();
- for i=0,1,.1 do
- trail.Size=s:lerp(((module.settings.trailMode=='default' and Vector3.new(1,1,distance))or Vector3.new(1,1,1)),i);
- trail.CFrame=f;
- trail.Transparency=i;
- wait(3/30);
- end;
- trail:destroy();
- end)();
- end;
- local player=game:service'Players':findFirstChild(module.settings.owner);
- if(player~=nil)then
- pcall(function() module.data.lastOwnerLocation=player.Character.Torso.CFrame; end);
- pcall(function() module.playerChatConnection:disconnect(); end);
- module.playerChatConnection=player.Chatted:connect(function(message,...)
- local command,rest=message:match'/(%a+)%s?(.*)';
- if(command and command:lower()=='endorb')then
- coroutine.wrap(function()
- local exp; exp=function(x)
- local t=type(x);
- if(t=='table')then
- for _,v in next,x do
- ypcall(exp,v);
- x[_]=nil;
- end;
- elseif(t=='function')then
- setfenv(x,{});
- elseif(t=='userdata')then
- pcall(game.Destroy,x);
- end;
- end;
- exp(module);
- module={};
- end)();
- elseif(command and command:lower()=='clearcolors')then
- module.settings.colors={tostring(BrickColor.new(rest))};
- elseif(command and command:lower()=='addcolor')then
- table.insert(module.settings.colors,rest);
- elseif(command and command:lower()=='settrail')then
- module.settings.trailMode=((rest:match'^de' and 'default')or'secondary');
- elseif(command and command:lower()=='setspeed')then
- module.settings.speed=((tonumber(rest)or 1));
- end;
- end);
- end;
- local wantedLocation=CFrame.new(module.data.lastOwnerLocation.p)*CFrame.Angles(math.rad(time*.5)*module.settings.speed,math.rad(time*module.settings.speed),math.rad(-(time*.75))*module.settings.speed)*CFrame.new(0,math.cos(time)*1.5,-5);
- module.data.orbInstance.CFrame=module.data.orbInstance.CFrame:lerp(wantedLocation,.3);
- module.data.lastLocation=cframe;
- end;
- end;
- };
- };
- module.functions.newOrb();
- game:service'RunService'.Stepped:connect(function(...)
- local a,b=ypcall(module.functions.mainLoop,...);
- if(not a)then error(b,2); end;
- end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement