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

How to shutdown a game for a player?

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

✓ Accepted answer

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!

2 comments

0

Thanks for the speedy reply!

0

Np, and welcome for the super slow comment! :)

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)

2 comments

0

Thanks for the speedy reply. I didn't know that they added this in.

0

Error on line 5.

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)

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