I used the a local variable in a function and when i want to check if the plr is banned it gives me an error.
Heres my code-
local DataStoreService = game:GetService('DataStoreService') local PermBanData = DataStoreService:GetDataStore('PermBanData') game.Players.PlayerAdded:Connect(function(plr) for _,v in pairs(PermBanData) do if plr.UserId == v then local currentReason = PermBanData:GetAsync(permbanReason) -- Where the error is. end end end) game.Players.PlayerAdded:Connect(function(plr) for _,v in pairs(Enforcers) do if plr.Name == v then plr.Chatted:Connect(function(permbanmsg) if string.lower(permbanmsg:sub(1, 8)) == ':permban' then local commandSplits = string.split(permbanmsg:sub(10, -1), ' ') local plrPermBanArg = PlayerArgument()(commandSplits[1]) local permbanReason = permbanmsg:sub(11 + commandSplits[1]:len(), -1) PermBanData:SetAsync(plr.UserId, permbanReason) plrPermBanArg:Kick('\n You have been kicked for violating Terms of Service. \n Enforcer: '..plr.Name..'\n Notes: '..permbanReason) end end) end end)
The parameters of GetAsync()
should be the player’s user id or the key used for the DataStore. So GetAsync(plr.UserId)