Hello, I’m not sure what I did wrong, anyone know a fix?
for i,v in pairs(Settings.Banned) do
if (Player.Name) == (v) then
--
end
end
Hello, I’m not sure what I did wrong, anyone know a fix?
for i,v in pairs(Settings.Banned) do
if (Player.Name) == (v) then
--
end
end
To use pairs, you need to use a table or group of data. For example you could do :GetChildren() On the workspace.
But Settings is a variable, not a workspace model. Does it still count?
Basically, settings is a require to a module. (The require module doesn’t error)
No, It also doesnt need to be something in workspace. A For loop is a way to loop through a set of data and read/write to that data. For a variable you dont do a for loop.
Use ipairs for arrays there’s several reasons why (I won’t be explaining this today, I’m also assuming it’s an array) .
According to the error, Settings.Banned was probably nil or didn’t exist, try printing Settings.Banned right before iterating and ensure it’s a table.
The banned variable in Settings should be a table in order for the for loop to work.
It is a table. I’ll just try to print it.
Okay so I just printed it and it prints nil, here’s the table, not sure what I did wrong.
local Banned = {
{"ROBLOX"}; -- {Username}
}
Yeah, it’s in the settings module.
(30 characters)
To be sure its the correct storage, the OP didn’t state whether it was or not,
Also @pqranoiddboy If this is a module i recommend using
local Settings = require(WhereverTheScriptIsStored)
The banned table should be in the module table. Try setting it by entering Settings.Banned = {}.
Oh yeah, that would make sense. Let me try.
Uh so it kind of printed this…
(I did print(Settings.Banned))
0xd5006fc23721427f
That’s good. Try it again now, that says that it isn’t nil.
I’ll try what @ArrantNickel suggested.
So I tried what you suggested, but it didn’t work. Still prints the same.
Your solution seems to be throwing an error because of the local statement. @pqranoiddboy Remove the local from behind the banned so that it doesn’t error.
Yeah, I did. I know that you can’t do local banned in another local statement.
I’ve got a solution. You should write it like this:
Settings = {
Banned = {
"ROBLOX" -- Username
}
}