Why wont a DataStore array work?
I am working on a ban script, anyway... upon starting the game it gives me this error: ServerScriptService.Script:11: attempt to index local 'banData' (a nil value)
Here is the script:
01 | game.Players.PlayerAdded:connect( function (player) |
02 | print ( "Loading banData for " .. player.UserId) |
04 | local dataStoreService = game:GetService( "DataStoreService" ) |
05 | local data = dataStoreService:GetDataStore( "banData" ) |
07 | local banData = data:GetAsync(player.UserId .. "Data" ) |
09 | print ( "banData loaded for " .. player.UserId) |
11 | if not banData [ 1 ] = = "" then |
12 | print ( "Player " .. player.UserId .. "attemped to join the game, but was kicked." ) |
13 | print ( "Reason: 'You have been banned by " .. banData [ 1 ] .. "for " .. banData [ 2 ] .. ". Please PM " .. banData [ 1 ] .. " to appeal the ban.'" ) |
14 | player.Kick( "You have been banned by " .. banData [ 1 ] .. "for " .. banData [ 2 ] .. ". Please PM " .. banData [ 1 ] .. " to appeal the ban." ) |
The data should look like this
4 | - { "AlphaGamer150" , "Testing" } |