How do i make a script that kicks every player in the game

I want to make a script that kicks every player in the experience. I dotn really know where to start doing this

2 Likes

Script
for local script

game.Players.LocalPlayer:Kick("kick")

for script if you add game.players.playeradded do this

game.Players.PlayerAdded:Connect(function(player) --player is added
	wait(1)
	player:Kick("kick") -- put a reason
end)

let me know if it has a error

3 Likes

This is a server script. (recommend to put this script into the ServerScriptService)

local Players = game:GetService("Players") --//Get The player service

local function KickAllPlayers() --//Function to Execute from wherever in this script
	for _, player in pairs(Players:GetPlayers()) do --//in pairs executes code for every child of a table sent to it, in our case the table in the players of your game. 
		player:Kick("Reason") --// Executes this for every player.
	end
end

wait(5)
KickAllPlayers() --//Call the kick func

--//or you can do as BubbleGummer Has Explained, all though this kicks all players at the exact same time.

3 Likes

This script is more reusable so its very useful! Nice job!

1 Like

#help-and-feedback:scripting-support is the right topic for this btw

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.