Whenever I load up my game, my ban datastore has an error “invalid key to ‘next’”. I have tried investigating the cause of this but I have no luck every time I try. Can anyone help me diagnose the problem and fix it in my script? Thanks for reading this!
Error:
Script:
local table1 = {42310359}
local data = game:GetService("DataStoreService"):GetDataStore("BannedUsers");
local banmessages = {"Server-Banned."}
while wait() do
table1 = {} -- clearing table
for _,bannedusers in next, data:GetAsync("bans") do
table.insert(table1,bannedusers)
end
for _,bannedusers in next, game.ReplicatedStorage.ServerbannedPlayers:GetChildren() do
table.insert(table1,bannedusers.Value)
end
for _,player in next, game.Players:GetPlayers() do
for _,bannedplayer in next, table1 do
if typeof(bannedplayer) == "number" then
if player.UserId == bannedplayer then
player:Kick(banmessages[math.random(1,#banmessages)]) -- Get WI-FI Anywhere you go. Hold up bgfufafagjgafegaerta
end
elseif typeof(bannedplayer) == "table" then
if player.UserId == bannedplayer.USER_ID then
local timetillunban = "Unknown"
if bannedplayer.TIME == "Permament" then
timetillunban = "Never"
end
player:Kick("Banned, Reason: "..bannedplayer.REASON.." Time banned: "..bannedplayer.TIMEBANNED.." Time till unban: "..bannedplayer.TIME.." ("..timetillunban..")") -- Get WI-FI Anywhere you go. Hold up bgfufafagjgafegaerta
end
end
end
end
end