so i have a table with some players, one is real (me) and the other 2 are just some random names
table looks like this:
_G.Admins = {“ItzVasi”, “JohnDoe”, “alex”}
problem is when i try to local them for some reason the script cant find any of them but when i manually insert the names instead of using “for i,v in pairs” the script finds the real players with no issues
script looks like this:
wait(4)
Players = game:GetService("Players")
Admins = _G.Admins
for i,v in pairs(Admins) do
if Players:FindFirstChild(v) then
print("found player "..tostring(v))
else
print("cant find player "..tostring(v))
end
end
Where is _G.Admins actually being set? It’s possible it could be set after the script is trying to access them.
Don’t use _G anyway. Just have a table of admin names, and if you really have to, use a module instead of _G.
local players = game:GetService("Players")
local admins = {"Admin1", "Admin2", "Admin3")
for _, admin in next, admins, nil do
print(players:FindFirstChild("Admin"))
end
That won’t work. tostring(v) is only being used to display if the player was found or not, and if the table contains admin names, it will error “Attempt to index string with ‘Name’”.
in another script, i need it sadly its tied with a much bigger script and using module script will need me to rewrite it
table loads fine, the script prints out each name and it even has a 4 second cooldown before running everything
18:44:21.119 cant find player ItzVasi - Server - Handler:15
18:44:21.119 cant find player JohnDoe - Server - Handler:15
18:44:21.119 cant find player alex - Server - Handler:15
omg thank you so much, i would have never noticed, that was actually the issue and to even top it off i wrote the name correctly on a separate script which made me even more confused because it worked perfectly there