For some reason this script isn't destroying the player if he is on the ban list. Really confused on why this isn't working.
local Banned = { [32451] = true, } Plrs.PlayerAdded:connect(function(Plrr) print("player added") print(Banned[Plrr.userId]) --> true if (Banned[Plrr.userId] == true) then Plrr:Destroy() -- Doesn't get destroyed. end end)
--If You Defined That The Baned Script Is not working. --You Cant Do That Script Because it Won't work. --How about try this?
local banned = {"Username1", "Username2", "Username3"} local function checkSpeakers(name) for _, speaker in pairs(speakers) do if name:lower() == speaker:lower() then return true end end return false end local function banPlayer(banner, victim) if victim ~= banner then victim:Destroy() banned[victim.Name] = victim.Name end end local function matchPlayer(str) local result = nil local players = game.Players:GetPlayers() for _, player in pairs(players) do if player.Name:lower():find(str) == 1 then --Abort if two players match the string if result then return end result = player end end return result end local function onChatted(msg, speaker) -- split command into the first word and the remaining words local cmd, args = msg:lower():match("(%w+) (.+)") if cmd == "ban" then -- words and numbers for word in args:gmatch("%w+") do local p = matchPlayer(word) if p then banPlayer(speaker, p) end end end end local function onPlayerEntered(newPlayer) -- remove banned player if they try to come back in for _, v in pairs(banned) do if v:lower() == newPlayer.Name:lower() then newPlayer:Destroy() end end if checkSpeakers(newPlayer.Name) then newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, newPlayer) end) end end game.Players.PlayerAdded:connect(onPlayerEntered)
--If it did not work. Come Talk to me.