vlatkovski

Remove Dropped Hats

Mar 30th, 2015
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.31 KB | None | 0 0
  1.  
  2. -- Made by Vlatkovski (I was really bored)
  3.  
  4. -- It has effects like slight sparkles and the hat 'blowing up'
  5.  
  6.  
  7.  
  8. local removeAfter = 3   -- Seconds to wait after removing hat
  9.  
  10.  
  11.  
  12.  
  13. --------------------------------------------------------------------------
  14. --------------------------------------------------------------------------
  15.  
  16. --don't touch the following
  17.  
  18.  
  19.  
  20. create, gp, gp2, c3, v3, ins, bc, cf, c255, v2 = LoadLibrary("RbxUtility").Create, UDim.new,  UDim2.new, Color3.new,  Vector3.new, Instance.new, BrickColor,  CFrame, function(r,g,b) return Color3.new(r/255, g/255, b/255) end, Vector2.new
  21.  
  22. --http://pastebin.com/hPuLMsVZ
  23. function findFirstChild(object, property, want, recursive) local property, recursive, found = property or "Name", recursive or false, nil; local function find(obj, prop, want) for i,v in next, obj:GetChildren() do local success, bool = pcall(function() return tostring(v[prop]) == tostring(want); end); if (success and bool) then found = v; break; elseif (recursive) then find(v, prop, want); end; end; end; find(object, property, want); return found; end;
  24.  
  25. function randomC3()
  26.     return c255(math.random(255), math.random(255), math.random(255));
  27. end;
  28.  
  29.  
  30. --main
  31. function removeHat(hat)
  32.     if (not hat:IsA("Hat")) or (not hat:IsA("Accoutrement")) then return; end;
  33.  
  34.     spawn(function()
  35.         delay(removeAfter, function()
  36.             if (not workspace:FindFirstChild(tostring(hat))) then return; end;
  37.        
  38.             local handle = findFirstChild(hat, "Name", "Handle");
  39.             local mesh = handle and findFirstChild(handle, "ClassName", "SpecialMesh");
  40.            
  41.             if (handle) and (mesh) then
  42.                 local function scale(n)
  43.                     mesh.Scale = v3(mesh.Scale.X+n, mesh.Scale.Y+n, mesh.Scale.Z+n);
  44.                 end;
  45.  
  46.                 ins("BodyGyro", handle);
  47.  
  48.                 local f = create "Fire" {
  49.                     Parent = handle;
  50.                     Heat = 1;
  51.                     Size = 2;
  52.                 };
  53.  
  54.                 for i=1,5 do
  55.                     scale(0.075);
  56.                     f.Color = randomC3();
  57.                     f.SecondaryColor = randomC3();
  58.                     wait(0.025);
  59.                 end;
  60.                 repeat
  61.                     scale(-0.075);
  62.                     f.Color = randomC3();
  63.                     f.SecondaryColor = randomC3();
  64.                     wait(0.05);
  65.                 until (mesh.Scale.X<=0 and mesh.Scale.Y<=0 and mesh.Scale.Z<=0);
  66.                
  67.                 hat:Destroy();
  68.             end;
  69.         end);
  70.     end);
  71. end;
  72.  
  73.  
  74.  
  75. --final
  76. workspace.ChildAdded:connect(removeHat);
  77.  
  78. for i,v in next, workspace:GetChildren() do
  79.     removeHat(v);
  80. end;
Advertisement
Add Comment
Please, Sign In to add comment