How do I ban people from my place?: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Armydude123
m rrrrrrrrrrrrreeeeeeeeeevvvvvvvvvvvv
>Police4000
No edit summary
Line 44: Line 44:
If Telamon and Teladude were in the place, saying "ban tela" would not ban either of them.
If Telamon and Teladude were in the place, saying "ban tela" would not ban either of them.


[[Category:Scripting Tutorials]]
==the final script==
this is the final script that you should have. there are some other ways but this is the way that i make them:
<pre>
speakers = {"?????"} -- Those who can say the command and in case there's already a name, delete that name and put there your own name
banned = {"?????","?????","?????"} -- Those who are banned
 
function check(name)
print(name)
        if #speakers == 0 then print("No speakers") return false end
        for i = 1,#speakers do
                if (string.upper(name) == string.upper(speakers[i])) then return true end
        end
        return false
end
 
function DisplayMessage(text, Wait, parent)
local message = Instance.new("Message")
message.Text = text
message.Name = "Message"
message.Parent = parent
wait(Wait)
if message ~= nil then
message.Parent = nil
end
end
 
function ban(name, source)
local player = game.Players:FindFirstChild(name)
if player ~= nil then
player.Parent = nil
table.insert(banned,player.Name)
end
end
 
function BreakDown(msg)
local sep = ", "
local str = sep..msg:sub(6)
fields = {str:match((str:gsub(sep.."[^"..sep.."]*", sep.."([^"..sep.."]*)")))}
 
 
return fields
end
 
function onChatted(msg, recipient, speaker)
 
local norm = msg
local msg = string.lower(msg)
 
if not (check(speaker.Name)) then return end
 
if string.sub(msg,1,5) == "/ban " then
local t = BreakDown(norm)
if msg == "/ban " then DisplayMessage("Please specify player(s)",2,speaker) return end
if #t > 0 then
for i = 1,#t do
print("\""..t[i].."\"")
local player = game.Players:FindFirstChild(t[i])
if player ~= nil then
ban(player.Name, speaker)
end
end
end
end
end
 
function onPlayerEntered(newPlayer)
print("entered")
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
for i=1, #banned do
if banned[i]:lower() == newPlayer.Name:lower() then
newPlayer.Parent = nil
end
end
end
 
game.Players.ChildAdded:connect(onPlayerEntered)
 
 
 
                                                                                                                    --police4000 <pre></pre>

Revision as of 16:11, 15 August 2008

Banning people from your place can be achieved by putting in a special command script. It can be edited much like a VIP door script.


Steps

1. Open your place in Roblox Studio.

2. Click on Insert to open the toolbox.

3. In the toolbox, click on Free Models.

4. Search for "Speak to Ban Player Script" (with quotes) and click on the LAST object that appears.


Now what?

This script adds the "ban" command to your game. Certain players can type "ban [player name]" in-game to ban an abusive player from your place.

In the Explorer panel, find BanScript and double-click on it. A scripting window will pop up. You can add your name to the speakers list, allowing you to use the command. You can also add your friend's name, if you want.

You can add a person's name to the banned list if you don't want them to enter your place. You will not have to use the ban command on them since they're already banned.

When banning someone, you don't need to type the player's full name, just enough letters to be sure of who you want to ban.

For example: if Builderman and Builderdude are in-game, "ban builderm" is enough. If Builderman and Telamon are the only people in the game, you can ban both by typing "ban b t"

Ambiguous bans are ignored. Example: Builderman and Builderdude are in-game. "ban bu" is ambiguous.


Recap

Adding a player's name to the speakers list will allow them to use the command.

Adding a player's name to the banned list will not allow them to enter the place.

Saying "ban telamon" will ban Telamon from the place.

Saying "ban telamon builderman" will ban Telamon and Builderman from the place.

If Telamon and Builderman were the only ones in the place, saying "ban t b" would ban them.

If Telamon and Teladude were in the place, saying "ban tela" would not ban either of them.

the final script

this is the final script that you should have. there are some other ways but this is the way that i make them:

speakers = {"?????"} -- Those who can say the command and in case there's already a name, delete that name and put there your own name
banned = {"?????","?????","?????"} -- Those who are banned

function check(name)
	print(name)
        if #speakers == 0 then print("No speakers") return false end
        for i = 1,#speakers do
                if (string.upper(name) == string.upper(speakers[i])) then return true end
        end
        return false
end

function DisplayMessage(text, Wait, parent)
	local message = Instance.new("Message")
	message.Text = text
	message.Name = "Message"
	message.Parent = parent
	wait(Wait)
	if message ~= nil then
		message.Parent = nil
	end
end

function ban(name, source)
	local player = game.Players:FindFirstChild(name)
	if player ~= nil then
		player.Parent = nil
		table.insert(banned,player.Name)
	end
end

function BreakDown(msg)
	local sep = ", "
	local str = sep..msg:sub(6)
	fields = {str:match((str:gsub(sep.."[^"..sep.."]*", sep.."([^"..sep.."]*)")))}


	return fields
end

function onChatted(msg, recipient, speaker)

	local norm = msg
	local msg = string.lower(msg)

	if not (check(speaker.Name)) then return end

	if string.sub(msg,1,5) == "/ban " then
		local t = BreakDown(norm)
		if msg == "/ban " then DisplayMessage("Please specify player(s)",2,speaker) return end
		if #t > 0 then
			for i = 1,#t do
				print("\""..t[i].."\"")
				local player = game.Players:FindFirstChild(t[i])
				if player ~= nil then
					ban(player.Name, speaker)
				end
			end
		end
	end
end

function onPlayerEntered(newPlayer)
	print("entered")
	newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
	for i=1, #banned do
		if banned[i]:lower() == newPlayer.Name:lower() then
			newPlayer.Parent = nil
		end
	end
end

game.Players.ChildAdded:connect(onPlayerEntered)



                                                                                                                     --police4000 <pre>