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:
game.Players.PlayerAdded:connect(function(player) print("Loading banData for " .. player.UserId) local dataStoreService = game:GetService("DataStoreService") local data = dataStoreService:GetDataStore("banData") local banData = data:GetAsync(player.UserId .. "Data") print("banData loaded for " .. player.UserId) if not banData[1] == "" then print("Player " .. player.UserId .. "attemped to join the game, but was kicked.") print("Reason: 'You have been banned by " .. banData[1] .. "for " .. banData[2] .. ". Please PM " .. banData[1] .. " to appeal the ban.'") player.Kick("You have been banned by " .. banData[1] .. "for " .. banData[2] .. ". Please PM " .. banData[1] .. " to appeal the ban.") end end)
The data should look like this
DATA > banData - 119226470Data -{"AlphaGamer150", "Testing"}
First time visitors (or anyone who's coming on that isn't banned) to your place won't have anything in banData, so as a result attempting to index it by using banData[1] will result in an error. What you should really do is use the following:
--This comment represents line 10 and before of your code if banData then --Using if (object) will evaluate if it exists or not --Continue from here