Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you search for a specific value in a dictionary?

I want to see if value1 is in a specific dictionary, and if so, it will run a function. How do I do that?

1 comment

0

You need to attempt before sending here.

1 answer

To do this make your dictionary as I've done and then use a for loop to iterate through them here's the code

local a = {}
a["Player1"] = 9

for i,v in pairs(a) do
if v == 9 then
return i --Player1
end

or If you don't want to do it like that you can use a table.insert function then return the thing you want.

table.insert(a,{ID = 2837472, stat = 288})

This discussion is preserved as it was. New answers, comments, and votes are closed.