-
Im trying to make a equip best button
-
i have this now and how can i check the highest multiplier and check how much space there is left and equip so much pets
game.ReplicatedStorage.EggHatchingRemotes.EquipBest.OnServerEvent:Connect(function(player, wwww, w, ww)
local numberOfPetsEquipped = #workspace.Player_Pets:FindFirstChild(player.Name):GetChildren()
local PetsTable = player.Pets:GetChildren()
local SpaceLeft = player.Values.MaxPetsEquipped.Value - numberOfPetsEquipped
if SpaceLeft > 0 then
print(SpaceLeft)
for i, v in pairs(game.ReplicatedStorage.Pets:GetDescendants()) do
if v:IsA("Model") then
print(v.Name)
for i, Pets in pairs(player.Pets:GetChildren()) do
if Pets.Name == v.Name then
local clonedPets = game.ReplicatedStorage.Pets:FindFirstChild(Pets, true):Clone()
clonedPets.Parent = workspace.Player_Pets:FindFirstChild(player.Name)
if player.Values.Multiplier1.Value == 1 then
player.Values.Multiplier1.Value += (clonedPets.Multiplier1.Value - 1)
else
player.Values.Multiplier1.Value += (clonedPets.Multiplier1.Value)
end
end
end
end
end
return "Equip"
elseif SpaceLeft < 0 then
print("No space left to equip!")
return "Cannot Equip"
end
end)