Advertisement
tusKOr661

Pet

Aug 19th, 2015
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.53 KB | None | 0 0
  1. --
  2. --Only change where indicated by --<'s
  3. --
  4. wait();
  5. script:Destroy();
  6. local module={
  7.     settings={
  8.         petOwner=game:service'Players'.localPlayer.Name;--<Change to your name
  9.         trailing=true;
  10.         petName='Just a pet';--<Change to a real name
  11.         petMood='Content';
  12.         petSize=Vector3.new(2,2,2);
  13.     };
  14.     petMoods={
  15.         ['Content']=BrickColor.new(1/0).Color;
  16.         ['Angry']=BrickColor.new('Really red').Color;
  17.         ['Sad']=BrickColor.new('New Yeller').Color;
  18.         ['Sick']=BrickColor.new('Dark green').Color;
  19.         ['Loved']=BrickColor.new('Hot pink').Color;
  20.     };
  21.     petData={
  22.         petObject=nil;
  23.         lastCFrame=CFrame.new();
  24.     };
  25. };
  26. local function trailObject(object)
  27.     spawn(function()
  28.         while(object:isDescendantOf(workspace))do wait();
  29.             local distance=(object.CFrame.p-module.petData.lastCFrame.p).magnitude;
  30.             if(distance>.2 and module.settings.trailing==true)then
  31.                 local trailPart=Instance.new('Part',object);
  32.                     trailPart.Anchored,trailPart.TopSurface,trailPart.BottomSurface,trailPart.CanCollide=true,'Smooth','Smooth',false;
  33.                     trailPart.Color=object.Color;
  34.                     trailPart.FormFactor='Custom';
  35.                     trailPart.Size=Vector3.new(0,0,distance);
  36.                     trailPart.CFrame=CFrame.new(module.petData.lastCFrame.p,object.CFrame.p)*CFrame.new(0,0,-distance/2);
  37.                     spawn(function()
  38.                         local p=trailPart.CFrame;
  39.                         wait(1);
  40.                         for i=0,1,.1 do wait();
  41.                             trailPart.Size=Vector3.new(i,i,distance);
  42.                             trailPart.CFrame=p;
  43.                             trailPart.Transparency=i;
  44.                         end;
  45.                         trailPart:destroy();
  46.                     end);
  47.             end;
  48.             module.petData.lastCFrame=object.CFrame;
  49.         end;
  50.     end);
  51. end;
  52. local function createPetInstance()
  53.     local petInstance=Instance.new('Part',workspace);
  54.         petInstance.Locked=true;
  55.         petInstance.Anchored=true;
  56.         petInstance.TopSurface='Smooth';
  57.         petInstance.BottomSurface='Smooth';
  58.         petInstance.Color=module.petMoods[module.settings.petMood];
  59.         petInstance.Size=module.settings.petSize;
  60.         petInstance.CFrame=CFrame.new(0,10,0);
  61.         trailObject(petInstance);
  62.     local bbg=Instance.new('BillboardGui',petInstance);
  63.         bbg.Size=UDim2.new(10,0,10,0);
  64.         bbg.StudsOffset=Vector3.new(0,2,0);
  65.     local fr=Instance.new('TextLabel',bbg);
  66.     local function resetFrData()--no more nooblets with gui editors
  67.         fr.BackgroundTransparency=1;
  68.         fr.Text=module.settings.petName;
  69.         fr.TextColor3=Color3.new(1,1,1);
  70.         fr.FontSize='Size24';
  71.         fr.Size=UDim2.new(1,0,1,0);
  72.     end;
  73.     fr.Changed:connect(resetFrData);
  74.     resetFrData();
  75.     return(petInstance);
  76. end;
  77. local function handleScript()
  78.     local pet,conn,reset;
  79.     function reset()
  80.         pcall(function() conn:disconnect(); end);
  81.         pet=createPetInstance();
  82.         conn=pet.AncestryChanged:connect(function()
  83.             pcall(game.Destroy,pet);
  84.             reset();
  85.         end);
  86.     end;
  87.     reset();
  88.     while true do local _,time=wait();
  89.         local cf=CFrame.new(0,10,0);
  90.         pcall(function() cf=game:service'Players':findFirstChild(module.settings.petOwner).Character.Torso.CFrame; end);
  91.         local wanted=CFrame.new(cf.p)*CFrame.Angles(0,math.rad(time)*100,0)*CFrame.new(0,0,-5)*CFrame.new(0,1.5*math.sin(tick()),0);
  92.         pcall(function()
  93.             pet.CFrame=CFrame.new(pet.CFrame.p:lerp(wanted.p,.3));
  94.         end);
  95.         if(math.random(1,200)==20)then
  96.             --update mood
  97.             local randomMood='';
  98.             local moods={};
  99.             for _,v in next,module.petMoods do
  100.                 moods[#moods+1]=_;
  101.             end;
  102.             randomMood=moods[math.random(1,#moods)];
  103.             module.settings.petMood=randomMood;
  104.             pcall(function() pet.Color=module.petMoods[randomMood] end);
  105.             pcall(function() game:service'Chat':Chat(pet,'Master, I am so '..randomMood:lower()..'!','Green') end);
  106.         end;
  107.     end;
  108. end;
  109. handleScript();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement