How do I use table.find to find an index in a dictionary?

local PlayerPosition = {
	["Player1"] = Vector3.new(14.25, 4, 7.175);
	["Player2"] = Vector3.new(9.725, 4, 7.175);
	["Player3"] = Vector3.new(9.725, 4, -1.625);
	["Player4"] = Vector3.new(14.25, 4, -1.625)
}

Above is my current table. Here is the line of code which is meant to print a Vector3 value from the table above:

print(v.Name, table.find(PlayerPosition, v.Name))

Right now, the script prints: Player1 nil (x371) (script is binded to a RenderStepped event)

You can’t use table.find on dictionaries.

Try this instead:

print(PlayerPosition[PlayerName])
7 Likes