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

Will this ban script work?

Here is the Portion of the script I dont know will work, Because I dont know how to make it to where if someone is in a table kick them on join.

if msg:sub(1,4) == "ban " then
	vic = msg:sub(1,9)
	m = Instance.new("Message")
	m.Parent = game.Workspace
	m.Text = (vic.Name.."Has Been Banned")
	wait(BanTime)
	m:Destroy()
	table.insert(vic, bans)
	game.Players.PlayerAdded:connect(function(vic)
	if vic.Humanoid.Health == 100 then
		vic:Kick()
	end
	end)
end

full script

admins = {"amegaman"}
bans = {""}
Time = 15
BanTime = 15
for i,v in pairs(IsAdmin) do
	return wait(Time)
end

if msg:sub(1,4) == "msg " then
	m = Instance.new("Message")
	m.Parent = game.Workspace
	m.Text = (Player.Name.."Says"..Player.Chatted)
	wait(Time)
	m:Destroy()
end

if msg:sub(1,4) == "ban " then
	vic = msg:sub(1,9)
	m = Instance.new("Message")
	m.Parent = game.Workspace
	m.Text = (vic.Name.."Has Been Banned")
	wait(BanTime)
	m:Destroy()
	table.insert(vic, bans)
	game.Players.PlayerAdded:connect(function(vic)
	if vic.Humanoid.Health == 100 then
		vic:Kick()
	end
	end)
end

2 answers

Have you tried it yet?

1 comment

1

No, But I have a Very good feeling it will kick everyone who has a health percentage of 100...

admins = {"amegaman"}
bans = {""}
Time = 15
BanTime = 15
--[[for i,v in pairs(IsAdmin) do
    return wait(Time)
end]] --This code doesn't appear to do anything. What's its purpose?

Game.Player.PlayerAdded:connect(function(plr) -- There are  a lot of edits in this, please ask if you don't understand any of them.
	wait() -- So that the Player has a chance to load fully, before kicking them if they are banned.
	for _, v in ipairs(bans) do
		if v == plr.Name then
		plr:Kick()
	end
	for _, v in ipairs(admins) do
		if v == plr.Name then
			plr.Chatter:connect(function(msg)
				msg = msg:lower() --small scrubbing, makes it easier to compare stuff
				if msg:sub(1,4) == "msg " then
				    m = Instance.new("Message")
				    m.Parent = game.Workspace
				    m.Text = plr.Name .. "Says" .. msg:sub(5)
				    wait(Time)
				    m:Destroy()
				end
				
				if msg:sub(1,4) == "ban " then
				    vic = Game.Players:FindFirstChild(msg:sub(5))
					if vic then
						m = Instance.new("Message")
						m.Parent = game.Workspace
						m.Text = (vic.Name .. "Has Been Banned")
					    wait(BanTime)
					    m:Destroy()
						table.insert(bans, vic.Name)
						vic:Kick()
					end
				end
			end)
			break
		end
	end
end)

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