How to fix this ban script?

  1. What do you want to achieve? Fix my ban script.

  2. What is the issue? My ban script was working fine and now its not working for some reason

  3. What solutions have you tried so far? I tried to look at devforum but i din’t found a solution.

Script:

local datastoreservice = game:GetService("DataStoreService") 
local bandata = datastoreservice:GetDataStore("TimedBans")

game.Players.PlayerAdded:Connect(function(plr)
	local data = bandata:GetAsync(plr.UserId) 
	if data[1] == plr.UserId then
		if os.time() >= data[2] then
			bandata:SetAsync(plr.UserId,{".",".","."})
		else
			local d = data[2] - os.time()
			local s = d / 86400 -- Days
			local f = math.round(s)
			
			
			plr:Kick("\n You have been banned\n For: "..data[3].."\n Day/Days Left Until Unban: "..f.."")
		end
	end
end)


at line 15, (plr:Kick()) its giving me this error: “Attempt to concatenate nil with string”, How i could fix this?

Is it a table you saved for a player, I mean what have you saved to your player ?

1 Like

try printing out data[3] and see if there is any output
else just set data[3] to a string with nothing in it

1 Like

i tried and i saw nil in output

then there is no data in data[3]
your saving must be a little wrong

What happens if you leave the “Reason” string empty when banning a player it will spit out nil i guess or just save nothing.
Either you save an empty string when nothing is entered or you just make the provided script check if there is data[3] and if not then just put an empty string right there

plr:Kick("\n You have been banned\n For: "..data[3] or "".."\n Day/Days Left Until Unban: "..f.."")

Not answered yet, how am I suppose to help then ?

You’re looping through player’s data dude. Can you tell me what’s saved in your player’s data ?

that is not a good ban script ill help you.

!@its been 2 hours how is it going??!!?!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.