- local function ActivateScripter()
- local Egg_Tool = script.Parent;
- local ServerStorage_EggData = game.ServerStorage.RareEggs;
- local onCooldown = false;
- local availableEggs = {
- ["CamoEgg"] = {};
- ["CashEgg"] = {};
- ["ComputerEgg"] = {};
- ["FireplaceEgg"] = {};
- ["MatrixEgg"] = {};
- ["MedicEgg"] = {};
- ["PaintingEgg"] = {};
- ["RobotEgg"] = {};
- ["SuitEgg"] = {};
- ["WorkerEgg"] = {};
- };
- -- Chances must go in ascending order ( Smallest to Highest );
- local rigged_Chances = { -- egg has to Available in the availableEggs and the maximum chance is 110%
- ["PaintingEgg"] = 5;
- ["FireplaceEgg"] = 15;
- ["MatrixEgg"] = 25;
- ["WorkerEgg"] = 35;
- ["SuitEgg"] = 45;
- ["ComputerEgg"] = 55;
- ["MedicEgg"] = 65;
- ["RobotEgg"] = 75;
- ["CashEgg"] = 85;
- ["CamoEgg"] = 95;
- };
- local function CloneEgg_Instructor(Egg_instanceName)
- pcall(function()
- local locateAvailableEggData = availableEggs[Egg_instanceName]
- if locateAvailableEggData then
- if Egg_Tool:FindFirstChild("Handle") then
- Egg_Tool.Handle:Destroy();
- end
- local NewEgg_Instance = ServerStorage_EggData[Egg_instanceName]:Clone();
- NewEgg_Instance.Name = "Handle";
- NewEgg_Instance.Parent = Egg_Tool
- end
- end)
- end
- local function findClosestCalculated_Egg(indicatedChance)
- local chosenEgg = nil
- local minCalcDifference = math.huge
- for _EGG, eggChanceCal in pairs(rigged_Chances) do
- local inDifference = math.abs(indicatedChance - eggChanceCal)
- if inDifference < minCalcDifference then
- minCalcDifference = inDifference
- chosenEgg = _EGG
- end
- end
- return chosenEgg;
- end
- Egg_Tool.Equipped:Connect(function()
- if onCooldown then
- else
- end
- pcall(function()
- local eggChildren = ServerStorage_EggData:GetChildren();
- if #eggChildren > 0 then
- local minAndMaxChances = math.random(1, 110);
- local chosenEgg = findClosestCalculated_Egg(minAndMaxChances)
- CloneEgg_Instructor(tostring(chosenEgg));
- wait();
- onCooldown = false;
- end
- end)
- end)
- end
- ActivateScripter();