Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Player:Kick() not showing message?

Asked by 5 years ago

I have a piece of code that looks like this:

for _,v in pairs(game.Players:GetChildren()) do
    v:Kick("Server shutdown")
end

But when it runs, it only says "You have been kicked from the game", without the "Server shutdown"! What is going on here?

0
are you sure? danglt 185 — 5y

1 answer

Log in to vote
-1
Answered by 5 years ago

When you do an enhanced loop you are accessing there model. In this case we want to get the element/folder. We do this by game.Players.LocalPlayer. That local player part is the player folder but since we don't add any conditions or arguments to this it runs it on all players. So the solution is to put a local script in the starter gui and then do game.Players.LocalPlayer:Kick("Your message")

0
So I can't kick them from the server? LuaConstructor 0 — 5y
0
You can, just do what I told you H_exadecimal 9 — 5y
Ad

Answer this question