I wanted to make my game server shutdown or kick all players when one of the player leave the server, how can I do that and let all the players see a text with reason?
game.Players.PlayerRemoving:Connect(function(plr) for i,v in pairs(game.Players:GetPlayers()) do v:Kick("You have been kicked because one of the player left the game") end)
I am noob with script and that's all what I tried with my game :/
Why exactly do you want to kick the players when someone leaves the game? Sounds like you'd have a lot of trolls going into servers and ending games like that.
The logic in your code is fine, just needed an 'end' after the for loop to end the loop. Here's how you'd do it:
local Players = game:GetService("Players") Players.PlayerRemoving:Connect(function(plr) for i,v in pairs(game.Players:GetPlayers()) do v:Kick("You have been kicked because a player left the game") end end)