What solutions have you tried so far? Searching the devforum but found nothing.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
function EggHandler:BuyEgg(egg, auto)
if MainUI:FindFirstChild("PetHatch") == nil and MainUI:FindFirstChild("MultiPetHatch") == nil then
if buyD == false and AutoDeleteFrame.Visible == false then
buyD = true
local eggName = egg.Name
local stats = self:GetEggStatsForEgg(eggName)
local cost,currency = EggHandler:GetEggCostCurrency(eggName)
if currency == "Robux" and stats.ProductID ~= nil and stats.ProductID2 ~= nil then
local productID = stats.ProductID
MarketPlaceService:PromptProductPurchase(Player, productID)
else
local pet = BuyEggEvent:InvokeServer(eggName, "Buy1")
if pet == "Max" then
print("Max Pets!")
buyD = false return true
elseif pet == "GetClose" then
print("Get Closer To Buy Egg!")
buyD = false return true
elseif pet == "Locked" then
print("Egg Is Locked! Unlock The Correct Area!")
buyD = false return true
elseif pet then
if pet[1] == "NeedMoney" then
local currencyName,amountNeeded = pet[2],pet[3]
local msg = "You do not have enough gems to purchase this egg!"
print("Not Enough Clicks!")
else
spawn(function()
local Data = GetPlayerData()
ShowPetsInEggsMod:ChangePetPercentages(Player, eggs, Data)
IndexUIModule.UpdateIndex(Data)
end)
local petName, newPet, shiny, autoDeleted = pet[1], pet[2], pet[3], pet[4]
EggService:HatchEgg(eggName, petName, newPet, nil, nil, shiny, autoDeleted, auto)
end
end
end
wait() buyD = false
end
end
end
function EggHandler:BuyEgg(plr, eggName, which)
if plr and eggName ~= nil and which ~= nil then
if self:CheckPetInv(plr, which) == true then
local canOpenEgg = self:CheckIfCanOpenEgg(plr, tostring(eggName))
if canOpenEgg == true then
if self:CheckEggDistance(plr, tostring(eggName)) == true then
if which == "Buy1" then
local cost, currency = self:GetEggCostCurrency(tostring(eggName))
local stat = plr.leaderstats[currency].Value
if tonumber(stat) >= tonumber(cost) then
plr.leaderstats[currency].Value = plr.leaderstats[currency].Value - tonumber(cost)
local pet = self:OpenEgg(plr, tostring(eggName), "OnePet")
if pet ~= nil then
self:AddTotalEggAmount(plr, 1)
plr.leaderstats.Eggs.Value = plr.leaderstats.Eggs.Value + 1
local autoDeleted = self:CheckAutoDeletePet(plr, tostring(pet))
if autoDeleted == true then
return {pet, false, false, true}
else
LegendaryPetChatModule:SendMessage(plr, "Pet", tostring(pet), tostring(eggName))
local new = self:AddPetToIndex(plr, tostring(pet))
local shiny = self:ReturnShinyChance(plr, tostring(eggName))
if shiny == true then
PetHandler:AddPet(plr, {PetName = tostring(pet), Evolution = "Shiny";})
return {("Shiny ".. tostring(pet)), new, true, false}
else
PetHandler:AddPet(plr, {PetName = tostring(pet)})
return {pet, new, false, false}
end
end
end
else
local amountNeeded = tonumber(cost) - tonumber(stat)
return {"NeedMoney", tostring(currency), amountNeeded}
end
elseif which == "Buy3" then
if CheckPass(plr, "ThreeEggOpen", "Check") == true then
local cost,currency = self:GetEggCostCurrency(eggName)
local stat = plr.leaderstats[currency].Value
local newCost = tonumber(cost) * 3
if tonumber(stat) >= tonumber(newCost) then
plr.leaderstats[currency].Value = plr.leaderstats[currency].Value - newCost
local pet1, pet2, pet3 = self:OpenEgg(plr, eggName, "ThreePets")
if pet1 ~= nil and pet2 ~= nil and pet3 ~= nil then
self:AddTotalEggAmount(plr, 3)
plr.leaderstats.Eggs.Value = plr.leaderstats.Eggs.Value + 3
local tbl1, tbl2, tbl3 = {}, {}, {}
local autoDeleted1 = self:CheckAutoDeletePet(plr, tostring(pet1))
local autoDeleted2 = self:CheckAutoDeletePet(plr, tostring(pet2))
local autoDeleted3 = self:CheckAutoDeletePet(plr, tostring(pet3))
if autoDeleted1 == true then
tbl1 = {tostring(pet1), false, false, true}
else
LegendaryPetChatModule:SendMessage(plr, "Pet", tostring(pet1), tostring(eggName))
local new1 = self:AddPetToIndex(plr, tostring(pet1))
local shiny1 = self:ReturnShinyChance(plr, eggName)
if shiny1 == true then
PetHandler:AddPet(plr, {PetName = tostring(pet1), Evolution = "Shiny";})
tbl1 = {("Shiny ".. tostring(pet1)), new1, true, false}
else
PetHandler:AddPet(plr, {PetName = tostring(pet1)})
tbl1 = {tostring(pet1), new1, false, false}
end
end
if autoDeleted2 == true then
tbl2 = {tostring(pet2), false, false, true}
else
LegendaryPetChatModule:SendMessage(plr, "Pet", tostring(pet2), tostring(eggName))
local new2 = self:AddPetToIndex(plr, tostring(pet2))
local shiny2 = self:ReturnShinyChance(plr, eggName)
if shiny2 == true then
PetHandler:AddPet(plr, {PetName = tostring(pet2), Evolution = "Shiny";})
tbl2 = {("Shiny ".. tostring(pet2)), new2, true, false}
else
PetHandler:AddPet(plr, {PetName = tostring(pet2)})
tbl2 = {tostring(pet2), new2, false, false}
end
end
if autoDeleted3 == true then
tbl3 = {tostring(pet3), false, false, true}
else
LegendaryPetChatModule:SendMessage(plr, "Pet", tostring(pet3), tostring(eggName))
local new3 = self:AddPetToIndex(plr, tostring(pet3))
local shiny3 = self:ReturnShinyChance(plr, eggName)
if shiny3 == true then
PetHandler:AddPet(plr, {PetName = tostring(pet3), Evolution = "Shiny";})
tbl3 = {("Shiny ".. tostring(pet3)), new3, true, false}
else
PetHandler:AddPet(plr, {PetName = tostring(pet3)})
tbl3 = {tostring(pet3), new3, false, false}
end
end
return tbl1, tbl2, tbl3
end
else
local amountNeeded = tonumber(newCost) - tonumber(stat)
return {"NeedMoney", tostring(currency), amountNeeded}
end
else
return "NeedPass"
end
end
else
return "GetClose"
end
else
return canOpenEgg
end
else
return "Max"
end
end
end