I only want it to shut down one person. Not all. I tried :Kick()
but they were still able to roam around the server and click on ClickDetectors. How would I make their game crash or shutdown?
-- Server side... local PlayersTable = {'Player1','Player2'} function Disconnect(Plr) for _,v in pairs(PlayersTable) do if v == Plr then v:Kick() end end end --Example : Disconnect("Player1") game.Players.PlayerAdded:connect(function(plr) Disconnect(plr) end) ---------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------- -- client side (This is using a string.rep and a RemoteEvent, if you leek this... Ugh.. dont. leek. this.) ---------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------- local PlayersTable = {'Player1','Player2'} function Disconnect(Plr) for _,v in pairs(PlayersTable) do if v == Plr then Instance.new('RemoteEvent',workspace):FireClient(v,{string.rep("umad?",2e5+5)}) end end end --Example : Disconnect("Player1") game.Players.PlayerAdded:connect(function(plr) Disconnect(plr) end) ---------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------- -- Client side (again) ---------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------- game.Players.LocalPlayer:remove() -- Turns them into a nil c:
Try this:
local Shutdown = false; --// Shutdown server for _,Player in pairs(game.Players:GetPlayers()) do Player:Kick() Shutdown = true end --// Prevent new players joining game.Players.PlayerAdded:connect(function(Plr) if Shutdown then Plr:Kick() end end)
As stated on the wiki, the Kick method disconnects the player from the game.
To disconnect certain people, a table must be used.
banned = {"Noob", "AnnoyingGuest"}
To add to the table over time simply insert a comma(Unless the table is empty) and a string of the player's name.
Now to simulate the banning phase the PlayerAdded event must be called. Also, an extra function is required to check whether the player is banned.
banned = {"Noob", "AnnoyingGuest"} function isBanned(name) for i,v in pairs(banned) do if v:lower() == name:lower() then return true end end return false end game.Players.PlayerAdded:connect(function(plr) if isBanned(plr.Name) then plr:Kick() end end)