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.
Combining the scripts will work as long as you do not try to create 1 variable name twice. Not doing this will cause the code after the second use to do what the second variable does. Putting two IsAdmins that are different in any part of the code will not work but if they are the same that is completely fine if you DON'T want to change what IsAdmin does in the code.
You would simply combine them! You would just need to rename any functions or variables that are the same so:
local speakers = {"1337ZombieGamer", "Person2", "Person3"} local banned = {"Havemeat", "Username2", "Username3"} local isAdmin = {["1337ZombieGamer"] = true} 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) function findPlayer(name) for _, player in ipairs(game.Players:GetPlayers()) do if player.Name:lower() == name:lower() then return player end end end function onChatt(message, player) -- changes this name 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) onChatt(message, player) end)-- and here scene it -----was the same function end)