I have a ban system, (reason, os.time, (only days), etc)
However, when fetching the player id and putting it into the ban datastore, I have ran into an error, the script looks a little something like this.
game.Players.PlayerAdded:Connect(function(plr) -- When a player joins the server
local data = bandata:GetAsync(plr.UserId) -- Ban Data
if data[1] == plr.UserId then
if os.time() >= data[2] then
bandata:SetAsync(plr.UserId,{".",".","."})
else
-- rest of the script would go down here after the else statement, like reason, time, kick, etc
The issue is that on the 3rd line of the code I sent (if data[1] == plr.UserId) it fails to “index nil with number” Not quite sure what it means, but I do know that errors like that are usually typos or incorrect variables, so if you guys need more code, you can ask for it, I will send the entire script if that would help.
I’ve tried searching a bit online, I’m relatively new to scripting, I got most of this code from mixed sources (free models, posts, internet, etc) and pieced it together, while trying to understand what each variable does.
The weird thing is, the script functions fine, it works, I can ban people with reason and the time does work, so I don’t really understand what the issue is.
At first I thought maybe it was loading in too fast or something so I added a wait(1) line at the top, all that did was not save the time and make the banning system act as a kick.
I am happy to provide more information if needed.
Again I am relatively new to scripting, I am completely open to critiquing and information! I really appreciate things like this because it helps me grow into a better scripter!
Appreciate it guys!