I have this code but this didn't work at all. Example code:
local ExampleTable = {"Player1Name", "Player2Name"} script.Parent.MouseButton1Click:Connect(function() if ExampleTable[game.Players.LocalPlayer.Name] then --Do this else --Do this end end)
Im basically trying to see if a player's name is inside of my local table.
A table (known as an array in most programming languages) is a list of values (which you already know) called elements. To set/read data from the table you use the following format Table[i] where i is the spot in the table you wish to set or read. so what you want is something like this
for i,v in ipairs(ExampleTable) do if v == game.Players.LocalPlayer.Name then --Do this else --Do this end end
i counts how many elements in the table it has found and v is the value of the element it is checking.