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

Why is this ban script not working?

So I have a script that is supposed to ban certain players upon joining. I used my alt as one of the people banned, and the script did nothing when I had my alt join the game.

I also tried to test the script in Test Mode, and output gave me nothing.

I have no idea why this script is not working. Can someone please help me?

Here's the script:

BannedPlayers = {"Player1", "Player3"}

game.Players.PlayerAdded:connect(function(Player)
	repeat wait(1) until Player.Character
	for k,v in pairs(BannedPlayers) do
		if Player.Name == v then
			Player:Destory()
		end
		end
end)

1 comment

0

Instead of using repeat wait until, you can use the character added event also. You can also use the Kick function to make their game shut down.

1 answer

✓ Accepted answer

You misspelled Destroy.

BannedPlayers = {"Player1", "Player3"}

game.Players.PlayerAdded:connect(function(Player)
    repeat wait(1) until Player.Character
    for i,v in pairs(BannedPlayers) do
        if Player.Name == v then
            Player:Destroy()
        end
        end
end)

1 comment

0

I feel really stupid... How did I not notice that? Either way, it's fixed. Thank you.

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