I was making a system which would take your tool and give you a specific amount of gems assigned in a module for each of the tools:

  OmegaCrimsonDumpling = { 
  cost = 14000000000;
  name = "OmegaCrimsonDumpling";
  diamond = 40;

And so basically when I try to check if the tool has the "diamond" string in the module I get an error.

The "check" code:

local module = require(game.ReplicatedStorage.PelmenStats)
workspace.FloppaTraderExchange101.Dialog.DialogChoiceSelected:Connect(function(plr, choice)
	print("1")
	if choice.Name == "Trade" then
		print("2")
		if plr.Character:FindFirstChildWhichIsA("Tool") then
			print("3")
			local tool = plr.Character:FindFirstChildWhichIsA("Tool")
			tostring(tool)
			if module.Stat[tool]:FindFirstChild("diamond") then -- Part with the error.
				print("4")
				print("Success")
			end
		end
	end
end)

Any possible solutions?

1 comment

0

You only use FindFirstChild on instances. When using tables you have to directly index them like how you did with [tool]