Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Blacklist/suspension system does not do anything?

I am trying to make a script to blacklist or suspend people from my game. The game is for people to come and try out scripts and exploit the game.

(The whole script won't find in the code box, sorry)

local suspended = {"Jxyzxrr"}

local blacklisted = {"bl"}

for i,v in pairs(game.Players:GetChildren()) do

if suspended == v.Name then

game.Players.LocalPlayer:Kick("Suspended for abusing. This is only temporary.")

elseif

blacklisted == v.Name then

game.Players.LocalPlayer:Kick("Blacklisted. This is permanent.")

end

end

Script above gives NO errors or doesn't do anything. It's a LocalScript inside Workspace.

1 comment

0

Please put in in the script format

2 answers

✓ Accepted answer

You're putting a local script inside of the workspace however you should be using a normal server-side script inside ServerScriptService.

That's the first part, the second part is that you should've used the PlayerAdded event in Players instead of looping through everything.

local Players = game:GetService("Players") --The player service
local Suspended = {""} --We'll keep a list of UserIds here so that the banned user can't just change their username.
Players.PlayerAdded:Connect(function(plr) --When a player joins
	for Index = 1,#Suspended do --We loop through the table 
		if plr.UserId == tonumber(Suspended[Index]) then --If the UserId of the player is in the table we kick them
			plr:Kick("Your account has been suspended from the game.") --We kick them, and give them the reason they were kicked.
		end
	end
end)

5 comments

0

yah, should work!

0

Worked, but why did you use Index and [Index]? I'm confused.

0

For Index and [Index], they're essentially the same thing. Indexing is used to read arrays. In the "For" loop, it increases the index by 1. With this, we'll find every single thing in the table, such as a userid.

1

This doesn't deserve a downvote ex dee, the code is a lil messy from the comments but other than that this is fine.

0

thx dude

First of all, you can't use local scripts in workspace, they wouldn't work. So switch to a normal script (server script) because workspace is server-sided. Second, suspended is a table. You were comparing a table with a string, and obviously that wouldn't work. So let's fix this. We would loop threw all players, check if they are in the blacklist or suspended table, and if so, we :Kick() them. Now I see that you used LocalPlayer, that's why you were using a local script, you can just use the "v" which is the player getting currently looped, if he's in the table, Kick'd. Also your setup works with only the first memeber of the table, which i'm assuming you wouldn't want, so we'd make it check all of them, which means more in pairs.

local suspended = {“Jxyzxrr”}
local blacklisted = {“bl”}

for i,v in pairs(game.Players:GetChildren()) do
	for _, b in pairs (blacklisted) do
		if v.Name = v then
			v:Kick(“blacklsisted”)
		end
	end	
	for _, s in pairs (suspended) do
		if v.Name = s then
			v:Kick(“Suspended”)
		end
	end
end

And that's it! You can see we used different names for each variable representing the value getting currently looped.

2 comments

0

It only checks once, using player entered would fix it.

0

yah, i just answered exactly his question, i took his script and fixed it, didn't want to do major changes.

This discussion is preserved as it was. New answers, comments, and votes are closed.