So I created a Admin and a Ban script based off of roblox's Tutorials and at the moment there both 2 seperate scripts but I want to make them into one main script...
Heres the admin script
local isAdmin = {["1337ZombieGamer"] = true}
function findPlayer(name)
for _, player in ipairs(game.Players:GetPlayers()) do
if player.Name:lower() == name:lower() then
return player
end
end
end
function onChatted(message, player)
if message:sub(1, 5) == "Reset" and isAdmin[player.Name] then
player.Character:BreakJoints()
end
end
game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message) onChatted(message, player) end)
end)
and heres the ban script
local speakers = {"1337ZombieGamer", "Person2", "Person3"}
local banned = {"Havemeat", "Username2", "Username3"}
local function checkSpeakers(name)
for i,v in pairs(speakers) do
if (string.upper(name) == string.upper(v)) then return true end
end
return false
end
local function banPlayer(banner, victim)
if (victim ~= banner) then
victim:Destroy()
banned[victim.Name] = victim.Name
end
end
local function matchPlayer(str)
local result = nil
local players = game.Players:GetPlayers()
for i,v in pairs(game.Players:GetPlayers()) do
if (string.find(string.lower(v.Name), str) == 1) then
if (result ~= nil) then return nil end
result = v
end
end
return result
end
local function onChatted(msg, recipient, speaker)
local source = string.lower(speaker.Name)
msg = string.lower(msg)
if (string.find(msg, "ban") == 1) then --- msg starts with "ban"
-- words and numbers
for word in msg:gmatch("%w+") do
local p = matchPlayer(word)
if (p ~= nil) then
banPlayer(speaker, p)
end
end
end
end
local function onPlayerEntered(newPlayer)
-- remove banned player if they try to come back in
for i,v in pairs(banned) do
if (v:lower() == newPlayer.Name:lower()) then
newPlayer:Destroy()
end
end
if checkSpeakers(newPlayer.Name) then
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
end
end
game.Players.PlayerAdded:connect(onPlayerEntered)
any idea? I would try to do this myself but I don't want to chance breaking anything.
