Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Equip more then one pet?

Asked by 4 years ago

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!

2 answers

Log in to vote
2
Answered by 4 years ago

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.

0
Thanks I’m ganna go try this and tweak it a little to see if i can work with it. ahsan666666666666 264 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

petsEquipped = 0 maxPetsAllowed = 3

if petsEquipped >= maxPetsAllowed then

end

Answer this question