Since you made your whitelist a dictionary, you don't need the loop.
This:
ALLOWED_ACCESS = {
[myid] = true,
[friendsid] = true,
[blablaid] = true,
}
function checkifallowed(userid)
for ids,allowed in pairs(ALLOWED_ACCESS) do
if ids == userid and allowed then
return true
else
return false
end
end
end
Can just be this:
ALLOWED_ACCESS = {
[myid] = true,
[friendsid] = true,
[blablaid] = true,
}
function checkifallowed(userid)
return ALLOWED_ACCESS[userid] or false
end
The or false is optional, but it's a good habit to return true or false rather than true or nil when a boolean is expected, so that if you were to print it or compare to false it would work as expected. That said, even having a function wrap this dictionary is probably unnecessary if it's only called from within this same script. If it were part of an API exposed from a module to other scripts, you'd want this to stay a function.
3 comments
depends what can he activate?
and when?
and what's the localscript?