Autocomplete on scripting doesnt work right


Sadly i had to see that my auto complete or however it calls doesnt work exactly good.

In the past there was an autocomplete what actions i could do on a table but it doesnt work

is that a bug, or how to fix it?

i’m pretty sure what you’re trying to do is table.find?
i honestly also thought you could use “find” on a table (WhitelistedPlayers.find(player.Name)), but unfortunatley that’s not the case! You have to use table.find(WhitelistedPlayers, player.Name), which is a built in function that returns the index of the value if found, or nil if nothing’s found
Any case, i think what you’re trying to achieve is:

local WhitelistedPlayers = {
    "TestUser",
}

game:GetService("Players").PlayerAdded:Connect(function(player)
    if table.find(WhitelistedPlayers, player.Name) then
        -- whitelisted player
    else
        -- non-whitelisted player
    end
end)

that is an array, keys are numbers not strings so you can do

local whitelistedPlayers = {"TestUser"} -- this is an array so keys are numbers

--correct
whitelistedPlayers[1] 

--wrong
whitelistedPlayers.TestUser

also move this to scripting support as this is a wrong category

1 Like