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

How to shutdown a game for a player?

Asked by
IXLKIDDO 110
9 years ago

What this is supposed to be for is for banned players, kicked players, etc. So far, I've created this function:

local Banned = {}

function isPlayerBanned(BanChk)
    for i, v in pairs(Banned) do
        if Banned == v then
            return true
        end
    end
end

game.Players.PlayerAdded:connect(function(newplayer)
    if playerBanned(newplayer.Name) then

The problem I get after the 12th line is that I don't know how to shutdown a player. Not remove their character so they can't spawn or interact with anything, but genuinely make the "game shutdown" message pop up for them so that all instances have stopped for them. Any help?

3 answers

Log in to vote
1
Answered by 9 years ago

There is actually an easy way to disconnect the players client! All you need to do is use the function Kick()

Here is some information in the ROBLOX wiki, provided in this link

If this helps, Up-vote and accept!

0
Thanks for the speedy reply! IXLKIDDO 110 — 9y
0
Np, and welcome for the super slow comment! :) alphawolvess 1784 — 9y
Ad
Log in to vote
1
Answered by
Cizox 80
9 years ago

This should help: http://wiki.roblox.com/index.php?title=API:Class/Player/Kick

Disconnects their client so it would essentially shutdown the game for them. The final product would be:

local banned = {}

function isPlayerBanned(player)
    for int, val in pairs(banned) do
        if val == banned then
            return true
        else
            return false
        end
    end
end

game.Players.PlayerAdded:connect(function(player)
    if isPlayerBanned(player) then
        player:Kick()
    end
end)
0
Thanks for the speedy reply. I didn't know that they added this in. IXLKIDDO 110 — 9y
0
Error on line 5. TheeDeathCaster 2368 — 9y
Log in to vote
0
Answered by
Sirade -2
8 years ago

local Banned = {}

function isPlayerBanned(BanChk) for i, v in pairs(Banned) do if Banned == v then return true end end end

game.Players.PlayerAdded:connect(function(newplayer) if playerBanned(newplayer.Name) then newplayer:Kick("Banned") end end)

Answer this question