So basically I’m making a game that uses the egg hatchery system and I’m almost done with it but I came across a problem, I can’t or don’t know how I can equip more then one pet. Right now I’m making it where when you equip another pet it gets rid of the one allready there and equips the pet you just clicked equip on.
If Script.Parent.Parent:FindFirstChild(“Pet”) == true then Script.Parent.Parent.Pet:Destroy()
And that’s how I’m doing it and then after that it equips it and everything. But I want to make it where u can equip more then one, or make a capacity of at least 5 which can later be increased if someone buys a game pass. So if I wanted to do this would I have to use int values or something to keep track of how many pets are equipped and if there’s more then 5 send an error? If anyone knows can they also post a sample script of how I would do this? And thanks!
I can't give you exact code because you didn't provide enough of your original code, but I can give you a solution.
You could save a variable/integer either in the script or in the player that counts how many pets are equipped, you could do this by adding 1 to the variable/integer every time a pet is equipped. And you could end it with something like this:
petsEquipped = 0 maxPetsAllowed = 3 if petsEquipped >= maxPetsAllowed then -- code here, presumably destroy the existing pet.. end
Also note you would have this code run whenever the player equips a new pet.
petsEquipped = 0 maxPetsAllowed = 3
if petsEquipped >= maxPetsAllowed then
end