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

How to make a ban script using tables?

Hello! I was wondering if anyone knows how to make a ban script using tables.

This is currently what i've got.

local name = {"Aiden_12114", "Amanda69"}

game.Players.PlayerAdded:Connect(function(player)
	if player.Name == name then
		player:Kick()
	end
end)

1 comment

0

Review how tables work. This will only be a temp bad for that one server only. Look at using a datastore to ban players across the game itself

1 answer

✓ Accepted answer

kingdom5 is wrong because that script is in every server and if its not im stupid and kingom5 is right.

local name = {"Aiden_12114", "Amanda69"}--banned people

game.Players.PlayerAdded:Connect(function(player)
	for i, v in pairs(name) do--looping through the names
		if v:lower() == player.Name:lower() then --:lower() makes all the letters lowercase
			player:Kick("Your banned!")
		end
	end
end)--Also they can just switch their name and then it wouldn't work so I'd recommend looking into UserId

If you do want commands for it then listen to kingdom5. You'll need to save tables in datastore with the people that are banned but if ur not bothered about it and will change it in studio (which is fine but I'd prefer commands).

1 comment

0

Thanks!

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