Issues with Table Finding a Name

Hi, I was making this function inside this dialogue script and I want to do something but I don’t know how after trying to fix it and search the problem up on google/youtube I couldn’t fix it.

  1. What do you want to achieve? when a player talks to the npc and player selects a dialogue option the code I want it to set the CurrentElement Value to None (this folder is in ServerStorage) and Delete any traint that has been gotten using old element Basically a mini wipe.

  2. What is the issue? The issue here is that 1. I don’t know how to make the script find a spesific Name of a table and once it finds it to destroy that part 2. I can’t find ways to solve it

  3. What solutions have you tried so far? I tried looking everywhere I asked the Roblox Script AI but the advice didn’t work, I tried searching it up but no results.

This function is located inside ModuleScript inside of SSS(ServerScriptService) it prints the currentTraits table but doesn’t print Working. if you need more information about the script or anything else tell me I will Provide you with it.

			PlayerDataFolder.CurrentElement.Value = "None"
			local currentTraits = HttpService:JSONDecode(PlayerDataFolder.Traits.Value) or {}
			print(currentTraits)
			if tostring(currentTraits):find("Element:") then
				print("Working")
			end
			if  currentTraits then
				--I am lost I don't know what to add
				PlayerDataFolder.Talents.Value = HttpService:JSONEncode(currentTraits);
			end
1 Like

I have Found a Way to remove the Trait but it has to be one by one so if anybody could tell me how to detect a table with a spesific name that would really help

I fixed the Issue it was simpler than I thought

if currentTraits then
				for i,v in pairs(currentTraits) do
					if tostring(i):find("Element:") then
						currentTraits[i] = nil;
					end
				end
				
				PlayerDataFolder.Talents.Value = HttpService:JSONEncode(currentTraits );
			end

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