Pets Module
This module aims to handle pet movements and replication on all clients.
Installation
In your wally.toml file, add this to your dependencies:
Import
You have two solutions to import this module, depending if you wish to import the Controller or the Service on your own, or if you let the module give you the right code.
Configuration
A file called PetsModule.config.lua is to be created in the folder ReplicatedStorage/Shared/Configs.
Explanation:
NameFramePath: The path to the BillboardGui that will be displayed above the pets, displaying the name and the rarity. Starts in the
ReplicatedStorage.ModelsPath: The path to the folder where the models of the pets are stored. Starts in the
ReplicatedStorage.Dog: The internal name of the pet. Can be anything, as long as it is unique.
Name: The name of the pet that will be displayed above it.
Power: The multiplier of the pet.
Rarity: The rarity of the pet. Can be one of those:
Common,Uncommon,Rare,Epic,Legendary,MythicalorExclusive.Movement: The movement type of the pet. Can be
WalkorFly.
Usage
Client Side
This method allows you to listen to an event sent by the PetsService and run a callback function whenever an event is received.
All those events, except OnPlayerPetsUpdated, are sent to both the client and the server. Server side, the player is sent as the first parameter.
List of events:
OnPetAdded: Called when a player owns a new pet. Sends the new pet as a parameter.
OnPetRemoved: Called when a pet is removed from a player. Sends the deleted pet as a parameter.
OnMaxOwnedUpdated: Called when the limit of owned pets from a player is updated. Sends the new limit as a parameter.
OnMaxEquippedUpdated: Called when the limit of equipped pets from a player is updated. Sends the new limit as a parameter.
OnPetsUpdated: Called when the player's pet list is updated (pet equipped / unequipped / deleted). Sends the list of all the pets owned by the player, and the list of the pets he has equipped.
OnPlayerPetsUpdated: Same thing as
OnPetsUpdated, but when another player updates his pets. Sends the player before the two other parameters.
Usage
Explanation
name: The name of the event you wish to listen to.
callback: The callback function that will be run whenever this event is received.
This method allows a player to toggle the visibility of all pets in the game. When set to false, no pets will be visible.
Usage
Explanation
visible: Whether pets are visible or not.
This method allows you to respawn a player's pets. It is mainly used when the player is teleported on a long distance, to avoid the travel time of the pets.
Usage
Explanation
pets: The list of the player's equipped pets.
Here are two methods to get the pets of the player.
Get all pets
This method returns the list of all the pets a player has in his inventory.
Explanation
player: The player for whom to modify the limit.
Get equipped pets
This method returns the list of all the pets a player has equipped.
Explanation
player: The player for whom to modify the limit.
Here are two methods to get the limits of pets for the player
Get owned limit
This method returns the limit of pets a player can own
Get equipped limit
This method returns the limit of pets a player can equip
Server Side
This method allows you to create a pet outside the default configuration specified above.
Usage
Explanation
name: The internal name of the pet.
config: The configuration of the pet. Same as for the configuration.
This method allows you to add a pet to a player. It returns a UUID specific to this pet for this player. Without this UUID, you can't equip it, unequip it or even remove it. By default, a player can't own more than 70 pets.
Usage
Explanation
player: The player to whom to add the pet.
pet: The internal name of the pet, specified in the configuration.
This method allows a player to equip a pet from his inventory. By default, the player can't equip more than 4 pets at a time.
Usage
Explanation
player: The player equipping the pet.
uuid: The UUID of the pet to equip.
This method allows a player to un-equip a pet from his inventory.
Usage
Explanation
player: The player un-equipping the pet.
uuid: The UUID of the pet to unequip.
This method allows a player to equip the best pets he has. Pets are ordered by their power, and not their rarity.
Usage
Explanation
player: The player equipping the pets.
This method removes a pet from a player's inventory. This cannot be undone, so be careful using it !
Usage
Explanation
player: The player to whom the pet is to be removed.
uuid: The UUID of the pet to remove.
Here are two methods to update the pets limit of a player.
Update owned pets limit
By default, this limit is set to 70.
Explanation
player: The player for whom to modify the limit.
amount: The new limit.
Update equipped pets limit
By default, this limit is set to 4.
Explanation
player: The player for whom to modify the limit.
amount: The new limit.
Here are two methods to get the pets of a player.
Get all pets
This method returns the list of all the pets a player has in his inventory.
Explanation
player: The player for whom to modify the limit.
Get equipped pets
This method returns the list of all the pets a player has equipped.
Explanation
player: The player for whom to modify the limit.