Facebook
From Champulse, 5 Months ago, written in Plain Text.
This paste is a reply to loadstring(game:HttpGet( from mate - view diff
Embed
Download Paste or View Raw
Hits: 280
  1. local function ActivateScripter()
  2.  local Egg_Tool = script.Parent;
  3.  local ServerStorage_EggData = game.ServerStorage.RareEggs;
  4.     local onCooldown = false;
  5.  local availableEggs = {
  6.   ["CamoEgg"] = {};
  7.   ["CashEgg"] = {};
  8.   ["ComputerEgg"] = {};
  9.   ["FireplaceEgg"] = {};
  10.   ["MatrixEgg"] = {};
  11.   ["MedicEgg"] = {};
  12.   ["PaintingEgg"] = {};
  13.   ["RobotEgg"] = {};
  14.   ["SuitEgg"] = {};
  15.   ["WorkerEgg"] = {};
  16.  };
  17.  -- Chances must go in ascending order ( Smallest to Highest );
  18.  local rigged_Chances = { -- egg has to Available in the availableEggs and the maximum chance is 110%
  19.   ["PaintingEgg"] = 5;
  20.   ["FireplaceEgg"] = 15;
  21.   ["MatrixEgg"] = 25;
  22.   ["WorkerEgg"] = 35;
  23.   ["SuitEgg"] = 45;
  24.   ["ComputerEgg"] = 55;
  25.   ["MedicEgg"] = 65;
  26.   ["RobotEgg"] = 75;
  27.   ["CashEgg"] = 85;
  28.   ["CamoEgg"] = 95;
  29.  };
  30.  local function CloneEgg_Instructor(Egg_instanceName)
  31.   pcall(function()
  32.    local locateAvailableEggData = availableEggs[Egg_instanceName]
  33.    if locateAvailableEggData then
  34.     if Egg_Tool:FindFirstChild("Handle") then
  35.      Egg_Tool.Handle:Destroy();
  36.     end
  37.     local NewEgg_Instance = ServerStorage_EggData[Egg_instanceName]:Clone();
  38.     NewEgg_Instance.Name = "Handle";
  39.     NewEgg_Instance.Parent = Egg_Tool
  40.    end
  41.   end)
  42.  end
  43.  local function findClosestCalculated_Egg(indicatedChance)
  44.   local chosenEgg = nil
  45.   local minCalcDifference = math.huge
  46.   for _EGG, eggChanceCal in pairs(rigged_Chances) do
  47.    local inDifference = math.abs(indicatedChance - eggChanceCal)
  48.    if inDifference < minCalcDifference then
  49.     minCalcDifference = inDifference
  50.     chosenEgg = _EGG
  51.    end
  52.   end
  53.   return chosenEgg;
  54.  end
  55.  
  56.  Egg_Tool.Equipped:Connect(function()
  57.   if onCooldown then
  58.    else
  59.   end
  60.    
  61.   pcall(function()
  62.    local eggChildren = ServerStorage_EggData:GetChildren();
  63.    if #eggChildren > 0 then
  64.     local minAndMaxChances = math.random(1, 110);
  65.     local chosenEgg = findClosestCalculated_Egg(minAndMaxChances)
  66.     CloneEgg_Instructor(tostring(chosenEgg));
  67.     wait();
  68.     onCooldown = false;
  69.    end
  70.   end)
  71.  end)
  72. end
  73. ActivateScripter();