Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Disconnecting a player?

:Disconnect() is supposed to "Disconnects the Roblox client from the given server. The associated player, if any, is removed on the server. Nothing happens on the client." AKA disconnect a player from the game.

So I used it in a simple script that disconnects the person from the game when they click a gui button:

script.Parent.MouseButton1Click:connect(function()
	game.Players.Player1:Disconnect()
end)

But when fired, it gave me "Disconnect is not a valid member of Player". So if that's not how I use the method, then how do you?

2 answers

Your script is relating it to the Events method, the disconnect of NetworkClient is protected.

This item is protected. Attempting to use it in a Script or LocalScript will cause an error.

Try using this.

3 comments

0

What does Protected mean?

0

Protected means only the Core Scripts inside of ROBLOX are allowed to run the command.

0

Exactly.

script.Parent.MouseButton1Click:connect(function()
    game.Players.Player1:Kick()
end)

Try the Kick() method this shall work and help you immensely. The Kick() method disconnects the player from the game.

~ Happy Scripting HexC3D

if this helped +1, if this answered your question check mark :)

1 comment

0

Oh, no wonder. I thought to look for a Kick method, but it wasn't on the list of methods so I assumed there wasn't one. http://wiki.roblox.com/index.php/Category:Methods

This discussion is preserved as it was. New answers, comments, and votes are closed.