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

Disconnecting a player?

Asked by
emite1000 335 Moderation Voter
10 years ago

: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

Log in to vote
2
Answered by
Tesouro 407 Moderation Voter
10 years ago

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.

0
What does Protected mean? emite1000 335 — 10y
0
Protected means only the Core Scripts inside of ROBLOX are allowed to run the command. TofuBytes 500 — 10y
0
Exactly. Tesouro 407 — 10y
Ad
Log in to vote
2
Answered by
HexC3D 830 Moderation Voter
10 years ago
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 :)

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 emite1000 335 — 10y

Answer this question