How to add certain values to this table?

I am trying to add Extra Stats to a Unique Weapon, i’ve already tried many ways, but i can’t seem to make it to work, can someone guide me in what should i do?

In my logic, Adding a table isn’t the most convenient, because when i want to set a value, instead of adding, it would add the same value, except if i do another function for the profile wrapper to set a Certain value

ProfileWrapper Module :

function ProfileWrapperPrototype:GetObjectWithIdentifier(UniqueId : string | number)
	local Character = self.Player.Character
	local Backpack = self.Player.Backpack

	local inventory_folder = Inventories[self.Player.Name]
	
	for _, tool in self.Replica.Data.tools do
		if tool.UniqueId ~= UniqueId then
			continue
		end

		return table.clone(tool)
	end
	
end
function ProfileWrapperPrototype:SetObjectExtraStats(Item, tablevalues)
	if Item then
		local clone_table = table.clone(Item)
		warn(clone_table)
		
-- logic would go here
		for i, values in pairs(clone_table) do
			warn(values)
		--	table.insert(clone_table["ExtraStats"], name)

		end
		task.wait(.1)
		warn(tablevalues)
		warn(clone_table)
	end
end

Init Script :

local Item = Profile:GetObjectWithIdentifier("1b58eb82-02cb-40eb-a")
	
	if Item then
		Profile:SetObjectExtraStats(Item, {
			["Damage"] = 5
		})
		
		warn(Item)
	end

image

A lot of the code here seems useless, why are you using table.clone() multiple times?
Anyway, the logic here:

should be

for Name, Value in pairs(tablevalues) do
       clone_table["ExtraStats"][Name] = Value
end

There’s a lot of missing knowledge that could be helpful in helping you, but that code should work.

1 Like

You are my hero, The table.clone it’s because i am using a Data Module Called Replica, so it can save, and then i do

	self.Replica:Set({ 'tools', "ExtraStats" }, clone_table)

atleast that’s the only way i’ve found to set the table to the values

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.