I've been working on a couple games and one of the last few things I want to implement is an ability to delete a pet using ABlox's egg and pet tutorial system.

I've literally spent 3 and a half days over the span of a couple weeks trying to figure it out and I have tried countless approaches and inadequate scripts to get something as simple as this done. This is still out of my league in the scripting that I have learned (i'm not good with tables or modules yet.) The closest I've got is printing the equipped pet's name and deleting the player's entire PetInventory folder.

I've been trying to implement a "KillPet" button that unequips the player's current pet and destroys a single copy of the string from the player's PetInventory folder (there can be multiple copies of the string because they do not stack, and I cannot figure out how to individualize each string yet.) This needs to be done on the server and then the datastore will update itself when the player leaves the game.

The pets are stored as a string value (name of pet) in the player's PetInventory folder. The equipped pet is stored as a string value "EquippedPet" in the player's folder.

Can anyone point me in the right direction to get started? I even have a copy of the system hosted on roblox and open sourced if it helps.

I would appreciate any help I could get. Thanks!!!

Image of Setup: https://ibb.co/gVSD4FL

Edit: Today's restarted progress:

local clickDetector = workspace.Button.ClickDetector

local function onMouseClick(player)
	print (player)
	local PI = player.PetInventory
	print (PI)
	local EP = player.EquippedPet.Value
        print (EP)
end
    
	 --All of the values print correctly whenever the button is clicked.
	--I need to figure out how to delete a string, if it is even possible.

clickDetector.MouseClick:connect(onMouseClick)