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"}

1 comment
Thanks for the help, but @kingdom5 has already helped me, but since you gave the same answer he did, I accepted your answer!