Ban/Unban script

I don’t think it’s unbanning. Is this meant to work in Studio?

2 Likes

If this appear in the output when you did the ban command. Then add a print(IsBanned) below it to check If the datastore was succesfully changed to true.

1 Like

I added the print command.

3 Likes

Do this

local IsBanned = BanStore:GetAsync(plr.UserId)[1]l
print(IsBanned)

and change the SetAsync from ban command to this

BanStore:SetAsync(PlayerInCommand.UserId, true)

3 Likes

This error is happening on line 24

 ServerScriptService.Blox.Modules.Script:24: attempt to index boolean with number

the line

local IsBanned = BanStore:GetAsync(plr.UserId)[1]
2 Likes

First of all, why it’s on the line 24?

And, try to do:

local BanData = BanStore:GetAsync(plr.UserId)
local IsBanned = BanData[1]
2 Likes

I’m banning myself, the print value comes out true.
But when I rejoin, I’m not getting kicked???

2 Likes

This is on the script?

If IsBanned  then
plr:Kick("Banned")
2 Likes

Yep.
image

2 Likes

There’s the issue. You’re not checking the boolean correctly. Change IsBanned to this and then do the If statement.

2 Likes

2 Likes

Weird… do print(IsBanned) below local IsBanned

2 Likes

I have to be somewhere. I’ll test it when I get home.

2 Likes

To me it seems like you are trying to find the unbanned player in-game by checking if they’re in game.Players, but assuming they’ve been kicked this would not work as they’d never be in game.Players. maybe try remove this check and just find userid by username?

2 Likes

Could you provide an example? I’m unsure how to do that.

Do you mean just remove the checks I implemented and just unban the player?

1 Like

Yeah, remove the check that checks if the player is in game.Players, because if a player were banned they wouldn’t be in the game :slight_smile:

1 Like

Right now, I’m currently having trouble even getting the data store to remember that I’m banned.

1 Like

Still waiting for a solution to this issue.