Issue finding string value after :Clone()

Sell Pet function with Gui and a string value proving to the server that the player owns the pet, saves to the datastore and is able to pull back up upon player entering the game again.

  1. What do you want to achieve? Keep it simple and clear!

I’ve began a local script to sell the pet. I’ve gotten as far as deleting the the button that shows in the players inventory making it appear to the player that the pet has been sold, It also gives the player some currency upon the sale for some currency back. (in the event they have that pet already as you can only equip one. (Purely cosmetic))

  1. What is the issue? Include screenshots / videos if possible!

The issue is when the button is cloned an IntValue is created as well with the pets name as the IntValue name and placed in PetsInventory folder simply as a string value It matches the name of the pet in replicated storage to prove to the server that the player owns the pet. The StringValue.Name is what I need to delete.

This is my issue, I cannot figure out how to grab the stringvalue name that the pet was cloned from, from the players PetInventory to destroy it. I’d want it to be able to tell which “bear” for example, I mean if I own, say 3 I do not believe that my string value is tied to that selection at all. And in the pet inventory if I have 3 pets named bear. Their names are all bear so if I did delete bear from the players inventory would it delete all the bears housed there?

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I haven’t found anything on the forum pertaining to this because I imagine that my lack of coding experience is simply put, showing. I haven’t been able to wrap my brain around how to even get the stringvalue name to test anything with it. I’m thinking I can try some form of :GetChildren() but unsure how to proceed from there.

Just hoping that I don’t have to restructure my pet system which I’m beginning to think I may just to have to.

Screenshots I believe will help.

^Bee cloned in StarterGui - Inventory GUI

^ Bee in Player Inventory
^ Bee in PetInventory as a named String Value

^Sold Pet and according to player it sold, they got money and the frame is gone, Upon reloading in they’ll be able to sell it again because its still in the PlayerInventory upon leaving.

^ Sold Pet with script below String value remains - Yes because I haven’t coded it but that’s my issue. Not sure how to find it.

Code that I’ve started so far.

local replicatedStorage = game:GetService("ReplicatedStorage")
local physicalPet = script.Parent.Parent

	if script.parent.Text == "Sell" then
		script.Parent.Text = "Sure?"
			script.parent.Text = "Sell"
	elseif script.Parent.Text == "Sure?" then
		game.Players.LocalPlayer.leaderstats.Candy.Value = game.Players.LocalPlayer.leaderstats.Candy.Value + 5

Kind of confused myself trying to type this because I’m unsure if I’m doing it in a way anyone will be able to interoperate but I’m hoping its sufficient.

1 Like

Not 100% sure if this is going to fix it, however this should be .Parent

1 Like

Can’t believe I missed that lol but no I’m going to have to rewrite the whole pet system. I do appreciate it.

1 Like