Ban script help?

I still have no clue whatsoever that could be the problem. Maybe the client script isn’t working as intended? Try debugging the issue there by printing Target.Text.

It printed correctly, no idea…

I found this post that appears to have had some kind of similar problem? Unsure. Ban script help

Hey! Can you send any errors you get? That would be appreciated! Thanks!

Not quite the solution there, the issue was originally on setting the data there. Perhaps you’re getting stopped by this?

Maybe I am. Let me remove it and try, and if it does work then… How would I secure the remote?

Sadly that was not the problem! aaaaaaaaaaaaaaaaaah

Looks like we’re going nuclear then. Run a full print-debugging method to see where the lines stop by throwing in printing functions between lines.

Printed up until print(“above setasync”) and then it died.

ban.OnServerEvent:Connect(function(player, playerToBan, reason)
	if not table.find(ADMIN, player.UserId) then return end
	print("below table.find")
	playeruserID = getUserIdFromUsername(playerToBan)
	print("below playeruserID definition")
	if playeruserID == 1 then
		print("below playeruserid == 1")
		print("Cannot Ban This User!")
		return
		else
		local success, errormessage = pcall(function()
			print("above setasync")
			BanData:SetAsync(playeruserID, true, reason)
			print("below setasync")
		end)
		if success then
			print("above playertoban = this and that")
			local playerToBan = Players:GetPlayerFromUserId(playeruserID)
			print("below playertoban")
			if playerToBan.Parent then
				print("below playertoban.parent")
				playerToBan:Kick(reason)
				print("below :kick")
			else
				return
			end
		end
	end
end)

Looks like you’re setting one argument too many. Besides, true isn’t needed. Just do BanData:SetAsync(playeruserID, reason). If the entry(or reason) exists, then they were banned.

1 Like

I’ll try it out tomorrow, thanks.

That is false, you can send instances, but its reference will be nil unless the instance exists on both the client and server.

The third parameter has to be an array ({}).
This should be enough:

:SetAsync(Key, Reason)

There is no reason to use the extra parameters if they are never being used in the future, that is most likely why it stops.

You haven’t defined ADMIN here.

simple do local banplayer = playerid

sorry did not mean to reply to you @THECOOLGENERATOR

but you want to do datastore so make a value for the banned player try it

You’re having so much trouble with this one script. Just use something pre-made and customize it, like my admin panel. It’s much better than fighting with your script to work, and my admin panel has time ban functions and all that stuff.

If you insist on using this script, you obviously can, just making a suggestion.

I saw you still didnt find any solution (i was lazy to scroll all replies), so that post was long time ago and i made a ban system for my friend, you can check it out here: Ban - Roblox

If you have any questions, ask me.

Edit: to test just say ban me pls in the chat

Thank you so much, i changed that and it worked. It kicked me, I changed the ban handler to instead of if banned == true to if banned then and it worked!

1 Like