Can i use GenerateGUID on my pets system

I don’t know if it’s a good thing or not to use it on my pet system

constructor.new = function(name, size, multiplier, rarities, weight)
	local proxy, pets = proxy.new(pets, {
		Name = name,
		Size = size,
		Multiplier = multiplier,
		Rarities = rarities,
		Weight = weight,
		Id = httpService:GenerateGUID(true),
		Equipe = false,
		CanDelete = true,
		Success = ""
	})
	pets[name] = proxy
	return proxy, pets
end

pets.__global = {
	Create = function(proxy, player: Player)
		local pet = getmetatable(proxy)
		if type(pet) ~= "table" or pet.__global ~= pets.__global then error("failed !") end
		local dataStore = DataStoreModule.new("Players", player.UserId)
		if dataStore.State ~= true then return end
		dataStore.Value.Pets[pet.__info.Id] = pet.__info
		return dataStore.Value.Pets[pet.__info.Id]
	end,
	
	Destroy = function(proxy, player: Player)
		local pet = getmetatable(proxy)
		if type(pet) ~= "table" or pet.__global ~= pets.__global then error("failed !") end
		local dataStore = DataStoreModule.new("Players", player.UserId)
		if dataStore.State ~= true then return end
		if dataStore.Value.Pets[pet.__info.Id] then
			dataStore.Value.Pets[pet.__info.Id] = nil
		else
			return
		end
		return "Destroy"
	end,
}

I mean why not? It generates a unique string, which is what you want, right?

2 Likes

It’s about preference and data size, as long as you’re not storing thousands of pets; your data structure is fine for one saving key.

For the preference side an ID can be nice to identify pets with; or allow unique references for operations like datastores or memorystores for each pet.

No issue for using it as a key in a table. UUIDs are practically unique (not impossible, but the probability of a collision is so close to 0% it might as well be) and so using them as an identifier is a risk-free move