DataStore and table bug

hi, i want to make an admin sistem but at the TempBann i used print to debug but it prints: “BannedData” instead of the table

this is the script:

local BannedModule = {}

local Banned

_G.TempBanned = {}


pcall(function()
_G.TempBanned = game:GetService("DataStoreService"):GetDataStore("BannedData")
end)

local DataStore = game:GetService("DataStoreService")
local BannedStore = DataStore:GetDataStore("BannedData")
Banned = _G.Banned


while wait(1) do
	for Time, Player in next, game.Players:GetPlayers() do
			if table.find(_G.TempBanned, Player.Name) then
				Player:Kick("You are Temporary banned!, ur bann time is: "..game:GetService("DataStoreService"):GetDataStore(Player.UserId.."-BanTime"))
			
		end
	end
end



return BannedModule

i dint use DataStore good?

1 Like

Did you accidentally post the wrong snippet? There is absolutely no occurrence of a print call. Do post any exception messages if there are.

Also don’t use next, use pairs, and don’t call wait in the conditional part of the while loop. Finally, don’t use _G, use module scripts instead

i made it, but it gives me the same error:

[22:27:13.442 - Workspace.Admin.AdminLoaderAndSettings.AdminModule.Admin.LocalData.BannedData:19: bad argument #1 to ‘find’ (table expected, got Object)]

In this line

You assign TempBanned to a table, but in the body of the function you’ve passed to pcall, you reassign it to a data store instance

1 Like

i deleted that print 30characters

Then something else is the issue, but since this code isn’t the current one you’re using I won’t be able to be of much help