Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ChampulseV0
- -- Last edited on 17/4/24
- local function ActivateScripter()
- local Egg_Tool = script.Parent;
- local ServerStorage_EggData = game.ServerStorage:WaitForChild("RareEggs");
- local cooldownActivated = false;
- local eggChildren = ServerStorage_EggData:GetChildren();
- local availableEggs = {
- ["CamoEgg"] = {};
- ["CashEgg"] = {};
- ["ComputerEgg"] = {};
- ["FireplaceEgg"] = {};
- ["MatrixEgg"] = {};
- ["MedicEgg"] = {};
- ["PaintingEgg"] = {};
- ["RobotEgg"] = {};
- ["SuitEgg"] = {};
- ["WorkerEgg"] = {};
- ["CommonEgg1"] = {};
- ["CommonEgg2"] = {};
- ["CommonEgg3"] = {};
- ["CommonEgg4"] = {};
- };
- -- 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;
- ["CommonEgg1"] = 105;
- ["CommonEgg2"] = 115;
- ["CommonEgg3"] = 125;
- ["CommonEgg4"] = 135;
- };
- local function CloneEgg_Instructor(Egg_instanceName)
- if cooldownActivated then
- return
- end
- pcall(function()
- local locateAvailableEggData = availableEggs[Egg_instanceName]
- if locateAvailableEggData and not cooldownActivated then
- cooldownActivated = true;
- 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;
- wait(0.5);
- cooldownActivated = false;
- 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 cooldownActivated then
- return
- end
- pcall(function()
- if #eggChildren > 0 and not cooldownActivated then
- local minAndMaxChances = math.random(1, 175);
- local chosenEgg = findClosestCalculated_Egg(minAndMaxChances)
- CloneEgg_Instructor(tostring(chosenEgg));
- end
- end)
- end)
- end
- ActivateScripter();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement