Table-based sell tool script not working

This is the script:

  local prox = script.Parent
    local tools = {
    ["Tool_1"] = 5,
    ["Tool_2"] = 10,
    ["Tool_3"] = 100
    }
prox.Triggered:Connect(function(player)
	local tool = player.Character:FindFirstChildWhichIsA("Tool").Name
	if table.find(tools, tool) then
		player.leaderstats.Money.Value += table.find(tools, tool)
		print(tool)
	end
end)

The Problem is that it doesn’t give me the money or it doesn’t print in the if table.find(tools, tool) then if I add this line:

  elseif not table.find(tools, tool) then
 print("Not Tool")

It prints Not Tool

I had problems using table.find before, such as not recognizing a value and not working at all.

I’d suggest you go through the table and if v == tool then you found the tool.

2 Likes

I already made this, i just want to optimize my script a little bit…