Why is this table.find not working?


Why does this return nil instead of 1?
I tried it without the tostring and also without having “Enum.Material.Concrete” in speech marks.
Why does this not work?

1 Like

because floormats is a dictionary not an array tablefind only searches numeric keys so it never finds the tostring(crmat) key

table.find(table, value) searches for a value, not a key .
In your table, "Enum.Material.Concrete" is a key.

2 Likes

How would I get it to search for the key then?

To search for a key, just use floormats[key] —no need for table.find

1 Like

you can try to do this

hum:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
local crmat=hum.FloorMaterial
local suc,eee=pcall(function()
return floormats[tostring(crmat)]
end)
print(suc,eee)
end)
1 Like

Oh yeah that seemed to work, I literally tried everything but that, thank you!

2 Likes

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