Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --SafeGuard Version 1.1.0 rewrite 3 Development Build 4
- local licenseKey = "105s106c106o107t107t103k106i105d"
- local g = game
- local plyrs = g:service("Players")
- local ws = g:service("Workspace")
- local lg = g:service("Lighting")
- local sgu = g:service("StarterGui")
- local sp = g:service("StarterPack")
- local d = g:service("Debris")
- local ss = g:service("SoundService")
- local sc = g:service("ScriptContext")
- if not script then
- local h = Instance.new("Message",Workspace)
- h.Text = "SafeGuard 1.1.0 rw3 FATAL ERROR | script is undefined!"
- wait(4)
- h:destroy()
- end
- local s = script
- local sbk = script
- if shared.SG_GENV == nil then
- shared.SG_GENV = {}
- shared.SG_GENV.math = math
- shared.SG_GENV.string = string
- shared.SG_GENV.table = table
- shared.SG_GENV.game = game
- end
- math = shared.SG_GENV.math
- string = shared.SG_GENV.string
- table = shared.SG_GENV.table
- if not script.Parent == nil then wait(.5) script:destroy() end
- wait(1)
- sg = {}
- sg.Functions = {}
- sg.Settings = {}
- sg.Data = {}
- sg.EmergeControl = {}
- sg.Services = {}
- sg.Commands = {}
- sg.Modules = {}
- sg.Players = {}
- sg.Sounds = {
- ["Beep"] = "http://www.roblox.com/asset/?id=15666462",
- ["Five"] = "http://www.roblox.com/asset/?id=29445395",
- ["Four"] = "http://www.roblox.com/asset/?id=29445378",
- ["Three"] = "http://www.roblox.com/asset/?id=29445358",
- ["Two"] = "http://www.roblox.com/asset/?id=29445339",
- ["One"] = "http://www.roblox.com/asset/?id=29445305"}
- sg.Init = {}
- sg.Settings.ProtectedUnit = "scottkid"
- sg.Settings.Service = "disabled"
- sg.Settings.EmergeControl = "disabled"
- sg.Settings.sysActivated = "check"
- sg.Settings.sysCreators = {}
- sg.Settings.MaxNumOfNotifications = 8
- sg.Settings.NotificationsEnabled = true
- sg.Settings.BreakLoop = false
- sg.Data.curVer = "1.1.0 rw3"
- sg.Data.NotAllowed = {"ikiled"}
- sg.Data.UpdateModels = {}
- sg.Data.LoadedScript = {}
- sg.Data.Services = {"BadgeService","CoreGui","StarterGui","ChangeHistoryService","Chat","CollectionService","ContentFilter","ContentProvider","ControllerService","Debris","FlagStandService","FriendService","Geometry","GuiService","GuidRegistryService","InsertService","Lighting","LocalBackpack","MeshContentProvider","NetworkClient","NetworkServer","Workspace","PhysicsService","RunService","ScriptContext","ScriptInformationProvider","Selection","SocialService","SoundService","SpawnerService","Stats","StarterPack","Teams","TeleportService","TextService","Timer","VirtualUser","Visit","RenderHooksService"}
- sg.Data.UpdateModuleAsset = nil
- sg.Data.AccessDenied = "Access Denied to "..sg.Data.curVer.." instance! | Code used - "
- sg.Data.AccessCode = "access1234"
- sg.Data.LastUpdatedNum = 1369011221
- sg.Data.LastUpdatedInfo = {
- ["Minutes"] = math.floor(sg.Data.LastUpdatedNum/(60)),
- ["Hours"] = math.floor(sg.Data.LastUpdatedNum/(60*60)),
- ["Days"] = math.floor(sg.Data.LastUpdatedNum/(60*60*24))
- }
- sg.Data.PermissionLevels = {
- ["System"] = 5,
- ["Administrator"] = 4,
- ["Moderator"] = 3,
- ["Trusted User"] = 2,
- ["User"] = 1,
- ["Unprivildged User"] = 0,
- ["Banned"] = -1
- }
- sg.Preregistered = {
- ["tusKOr661"] = "Administrator",
- ["4byte"] = "Administrator"
- }
- setmetatable(sg,{__call = function() return script end})
- sg.Functions.AddNewScript = function(ins)
- if ins == script then return end
- if ins:isA"Script" or ins:isA"LocalScript" then
- if not ins:findFirstChild("DSource") then return end
- sg.Data.LoadedScript[ins.Name] = ins
- sg.Functions.gNotification("New Script "..ins:GetFullName().." was added to the database!")
- end
- end
- game.DescendantAdded:connect(sg.Functions.AddNewScript)
- sg.Functions.AntiChange = function(p)
- if p == "Parent" then
- script:destroy()
- script.Changed:connect(sg.Functions.AntiChange)
- pcall(function() sg.Functions.ReconnectConnections() end)
- elseif p == "Disabled" then
- script.Disabled = false
- else
- script.Archivable = false
- script.Name = "SafeGuard "..sg.Data.curVer
- end
- end
- sg.Functions.AntiRemove = function(i)
- if i == script then
- script:destroy()
- script.Changed:connect(sg.Functions.AntiRemove)
- pcall(function() sg.Functions.ReconnectConnections() end)
- end
- end
- sg.Functions.ReconnectConnections = function()
- for i,v in pairs(plyrs:GetPlayers()) do
- coroutine.wrap(function()
- pcall(function()
- while v.PlayerGui["SafeGuard_GUI"]["Msg"] do
- v.PlayerGui["SafeGuard_GUI"]["Msg"]:destroy()
- end
- end)
- end)()
- coroutine.wrap(function()
- pcall(function()
- v.Chatted:connect(function(chat,ins) sg.Functions.OnChatted(chat,v) end)
- end)
- end)()
- coroutine.wrap(function()
- pcall(function() v.PlayerGui["SafeGuard_GUI"]:destroy() end)
- local a = Instance.new("ScreenGui",v.PlayerGui)
- a.Name = "SafeGuard_GUI"
- end)()
- wait()
- sg.Functions.Notification(v,"Your connections were reconnected!")
- end
- plyrs.PlayerAdded:connect(function(p) sg.Functions.RegisterPlayer(p,1) end)
- end
- script.Changed:connect(sg.Functions.AntiChange)
- script.Parent.DescendantRemoving:connect(sg.Functions.AntiRemove)
- sg.Functions.PlaySound = function(soundName)
- if not sg.Sounds[soundName] then return end
- if not ws[soundName] then
- local s = Instance.new("Sound",ws)
- s.Name = soundName
- s.SoundId = sg.Sounds[soundName]
- s.Volume = 1
- s.Pitch = 1
- end
- wait()
- if not ws[soundName] then return end
- pcall(function() ws[soundName]:play() end)
- end
- sg.Functions.TripleBeep = function()
- coroutine.wrap(function()
- for i=1,3 do
- pcall(function() sg.Functions.PlaySound("Beep") end)
- wait(.1)
- end
- end)()
- end
- sg.Functions.CountDown = function()
- coroutine.wrap(function()
- sg.Functions.PlaySound("Five")
- wait(1)
- sg.Functions.PlaySound("Four")
- wait(1)
- sg.Functions.PlaySound("Three")
- wait(1)
- sg.Functions.PlaySound("Two")
- wait(1)
- sg.Functions.PlaySound("One")
- wait(1)
- end)()
- end
- sg.Functions.CreateModule = function(moduleName,loadFunction,unloadFunction,permissionLevel,description)
- sg.Modules[moduleName] = {
- ["Load"] = loadFunction,
- ["Unload"] = unloadFunction,
- ["PermissionLevel"] = permissionLevel,
- ["Description"] = description,
- ["Call"] = {}}
- if not sg.Modules[moduleName] then sg.Functions.gNotification("Failed to create module "..moduleName.."!") return end
- end
- sg.Functions.LoadModule = function(moduleName)
- local modu = sg.Functions.GetModule(moduleName)
- if not modu then return end
- Func,Error = loadstring(modu:Load(modu.Call))
- setfenv(Func,{__ENV = getfenv(1)})
- end
- sg.Functions.GetModule = function(moduleName)
- if not sg.Modules[moduleName] then sg.Functions.gNotification("Couldn't find Module "..moduleName.."!") return end
- return sg.Modules[moduleName]
- end
- sg.Functions.AddCommand = function(commandName,commandChat,callFunc,permissionRequirement,description)
- sg.Commands[commandName] = {
- ["CommandName"] = commandName,
- ["CommandChatCall"] = commandChat,
- ["CommandFunction"] = callFunc,
- ["CommandPermissionRequirement"] = permissionRequirement,
- ["CommandDescription"] = description}
- if not sg.Commands[commandName] then
- sg.Functions.gNotification("Unable to add command "..commandName.."!")
- end
- end
- sg.Functions.GetCommand = function(commandName)
- if not sg.Commands[commandName] then return "NONEXISTANT_COMMAND" end
- return sg.Commands[commandName]
- end
- sg.Functions.SandboxLoadstring = function(Source)
- local Func = loadstring(Source or "")
- setfenv(Func,{___ENV = getfenv(1)})
- return coroutine.wrap(Func)
- end
- sg.Functions.Loadstring = function(source,Speaker)
- local Func,error = loadstring(source)
- if error == nil then
- coroutine.wrap(function()
- Func()
- end)()
- sg.Functions.Notification(Speaker,"QuickScript successful!")
- else
- sg.Functions.Notification(Speaker,"QuickScript failed! ERROR - "..tostring(error))
- end
- end
- sg.Functions.GetMaxScreenSize = function(player)
- if not player:FindFirstChild("PlayerGui") then
- pcall(function()
- Instance.new("PlayerGui",player)
- end)
- pcall(function()
- local a = Instance.new("ScreenGui",player["PlayerGui"])
- a.Name = "SafeGuard_GUI"
- end)
- end
- if not player:FindFirstChild("PlayerGui") then return end
- if not player["PlayerGui"]:findFirstChild("SafeGuard_GUI") then
- pcall(function()
- local a = Instance.new("ScreenGui",player["PlayerGui"])
- a.Name = "SafeGuard_GUI"
- end)
- end
- if not player["PlayerGui"]:FindFirstChild("SafeGuard_GUI") then return end
- local sg = player["PlayerGui"]["SafeGuard_GUI"]
- local frame = Instance.new("Frame",sg)
- frame.Visible = false
- frame.Size = UDim2.new(1,0,1,0)
- local maxSize = frame.AbsoluteSize
- frame:destroy()
- print(maxSize)
- return mmaxSize
- end
- sg.Functions.GetMaxScreenPosition = function(player)
- if not player:FindFirstChild("PlayerGui") then
- pcall(function()
- Instance.new("PlayerGui",player)
- end)
- pcall(function()
- local a = Instance.new("ScreenGui",player["PlayerGui"])
- a.Name = "SafeGuard_GUI"
- end)
- end
- if not player:FindFirstChild("PlayerGui") then return end
- if not player["PlayerGui"]:findFirstChild("SafeGuard_GUI") then
- pcall(function()
- local a = Instance.new("ScreenGui",player["PlayerGui"])
- a.Name = "SafeGuard_GUI"
- end)
- end
- if not player["PlayerGui"]:FindFirstChild("SafeGuard_GUI") then return end
- local sg = player["PlayerGui"]["SafeGuard_GUI"]
- local frame = Instance.new("Frame",sg)
- frame.Visible = false
- frame.Position = UDim2.new(1,0,1,0)
- local maxPosition = frame.AbsolutePosition
- frame:destroy()
- print(maxPosition)
- return maxPosition
- end
- sg.Functions.RegisterPlayer = function(player,playerPermissionLevel)
- if player.Name == sg.Settings.ProtectedUnit then playerPermissionLevel = "Administrator" end
- if sg.Preregistered[player.Name] then playerPermissionLevel = sg.Preregistered[player.Name] end
- if sg.Players[player.Name] then
- sg.Players[player.Name]["PlayerInstance"] = player
- coroutine.wrap(function()
- pcall(function() player["PlayerGui"]["SafeGuard_GUI"]:destroy() end)
- pcall(function() local a = Instance.new("ScreenGui",player.PlayerGui) a.Name = "SafeGuard_GUI" end)
- end)()
- if sg.Functions.CheckIfBanned(player.Name) then return end
- sg.Functions.CheckScriptingAllowed(player.Name)
- if pcall(function() player.Chatted:connect(function(chat,ins) sg.Functions.OnChatted(chat,player) end) end) then
- sg.Functions.gNotification("Welcome back "..player.Name.."!")
- else
- sg.Functions.gNotification("Welcome back "..player.Name.."!")
- sg.Functions.Notification("It appears we failed to connect your commands! Please report this to SafeGuardAB!")
- end
- return
- end
- sg.Players[player.Name] = {
- ["PlayerInstance"] = player,
- ["PlayerName"] = player.Name,
- ["PlayerFullName"] = player:GetFullName(),
- ["PermissionLevel"] = sg.Data.PermissionLevels[playerPermissionLevel],
- ["UserID"] = player.userId,
- ["isBanned"] = false,
- ["scriptingAllowed"] = true,
- ["MaxUDim2Size"] = sg.Functions.GetMaxScreenSize(player),
- ["MaxUDim2Position"] = sg.Functions.GetMaxScreenPosition(player)}
- if not sg.Players[player.Name] then
- sg.Functions.gNotification("Failed to create Player Index for Player "..player.Name.."!")
- sg.Functions.Notification(player,"I was unable to create your Registeration. Please report this error to SafeGuardAB!")
- wait(3)
- player:destroy()
- else
- if sg.Functions.CheckIfBanned(player.Name) then return end
- sg.Functions.gNotification("Everyone welcome "..player.Name.." to the server!")
- sg.Functions.Notification(player,"SafeGuard has successfully registered you! Your permission level is "..sg.Players[player.Name].PermissionLevel.."!")
- wait(3)
- sg.Functions.Notification(player,"Connecting your Commands...")
- if pcall(function() player.Chatted:connect(function(chat,ins) sg.Functions.OnChatted(chat,player) end) end) == false then
- sg.Functions.Notification(player,"Failed to connect your commands! Please report this error to SafeGuardAB!")
- else
- sg.Functions.Notification(player,"Your commands were connected successfully! Permission Level - "..sg.Players[player.Name]["PermissionLevel"]..". |")
- end
- end
- end
- sg.Functions.GetPlayer = function(playerName)
- if not sg.Players[playerName] then return "NONEXISTANT_PLAYER" end
- return sg.Players[playerName]
- end
- sg.Functions.GetPlayerInstance = function(playerName)
- if not sg.Players[playerName] then return "NONEXISTANT_PLAYER" end
- return sg.Players[playerName].PlayerInstance
- end
- sg.Functions.CheckIfBanned = function(playerName)
- local p = sg.Functions.GetPlayer(playerName)
- if p == "NONEXISTANT_PLAYER" then
- for i,v in pairs(sg.Data.NotAllowed) do
- if v:lower() == playerName:lower() then
- return true
- end
- end
- end
- if p.isBanned == true then
- ypcall(function() plyrs:findFirstChild(p["PlayerName"]):destroy() end)
- sg.Functions.gNotification("Player "..p["PlayerName"].." is banned from this server!")
- return true
- else
- return false
- end
- end
- sg.Functions.gNotification = function(message)
- if sg.Settings.NotificationsEnabled == false then return end
- --sg.Functions.TripleBeep()
- for i,v in pairs(plyrs:GetChildren()) do
- if not v:findFirstChild("PlayerGui") then pcall(function() Instance.new("PlayerGui",v) end) end
- if not v:findFirstChild("PlayerGui") then return end
- if not v["PlayerGui"]:findFirstChild("SafeGuard_GUI") then local a = Instance.new("ScreenGui",v.PlayerGui) a.Name = "SafeGuard_GUI" end
- if not v["PlayerGui"]:findFirstChild("SafeGuard_GUI") then return end
- if not v.PlayerGui["SafeGuard_GUI"]:findFirstChild("MsgFrame") then local b = Instance.new("Frame",v.PlayerGui["SafeGuard_GUI"]) b.Name = "MsgFrame" end
- if not v.PlayerGui["SafeGuard_GUI"]:findFirstChild("MsgFrame") then return end
- coroutine.wrap(function()
- local pro = sg.Functions.GetPlayer(v.Name)
- if pro == "NONEXISTANT_PLAYER" then return end
- local gui = v["PlayerGui"]["SafeGuard_GUI"]["MsgFrame"]
- local f = Instance.new("Frame",gui)
- f.Name = "Msg"
- f.ZIndex = 7
- f.Visible = false
- local t = Instance.new("TextButton",f)
- t.Name = "MessageBox"
- t.Text = "SafeGuard "..sg.Data.curVer.." | "..tostring(message)
- t.FontSize = "Size12"
- f.Visible = false
- f.ZIndex = 7
- t.TextWrap = true
- t.Size = UDim2.new(0,1000,0,50)
- f.Position = UDim2.new(0,0,0,-51)
- f.Visible = true
- local Clicked = false
- local mouseOver = false
- coroutine.wrap(function()
- t.MouseEnter:connect(function()
- mouseOver = true
- t.BackgroundColor3 = BrickColor.new("Bright red").Color
- t.Text = "Click to dismiss!"
- end)
- t.MouseLeave:connect(function()
- mouseOver = false
- t.BackgroundColor3 = BrickColor.new("Medium stone grey").Color
- t.Text = "SafeGuard "..sg.Data.curVer.." | "..tostring(message)
- end)
- end)()
- t.MouseButton1Click:connect(function()
- Clicked = true
- t.Text = ""
- t:TweenPosition(UDim2.new(0,0,0,-51),"Out","Quad",1.5)
- for i=1,10 do
- t.BackgroundTransparency = t.BackgroundTransparency + .1
- wait(.01)
- end
- wait()
- f:destroy()
- end)
- coroutine.wrap(function()
- local ins = #gui:GetChildren()
- if ins <= sg.Settings.MaxNumOfNotifications then
- local t = 50*ins+300
- f:TweenPosition(UDim2.new(0,0,0,t))
- else
- f:destroy()
- print("Too many")
- end
- end)()
- coroutine.wrap(function()
- wait(8)
- while wait() do
- if mouseOver == false then
- t.BackgroundColor3 = BrickColor.new("Bright red").Color
- t.Text = "Click to dismiss!"
- wait(1.5)
- t.BackgroundColor3 = BrickColor.new("Medium stone grey").Color
- t.Text = "SafeGuard "..sg.Data.curVer.." | "..tostring(message)
- wait(3)
- end
- end
- end)()
- end)()
- end
- end
- sg.Functions.Notification = function(v,message)
- if pcall(function() v:findFirstChild("PlayerGui") end) == false then return end
- if not v:findFirstChild("PlayerGui") then pcall(function() Instance.new("PlayerGui",v) end) end
- if not v:findFirstChild("PlayerGui") then return end
- if not v["PlayerGui"]:findFirstChild("SafeGuard_GUI") then local a = Instance.new("ScreenGui",v.PlayerGui) a.Name = "SafeGuard_GUI" end
- if not v["PlayerGui"]:findFirstChild("SafeGuard_GUI") then return end
- if not v.PlayerGui["SafeGuard_GUI"]:findFirstChild("MsgFrame") then local b = Instance.new("Frame",v.PlayerGui["SafeGuard_GUI"]) b.Name = "MsgFrame" end
- if not v.PlayerGui["SafeGuard_GUI"]:findFirstChild("MsgFrame") then return end
- coroutine.wrap(function()
- local gui = v["PlayerGui"]["SafeGuard_GUI"]["MsgFrame"]
- local f = Instance.new("Frame",gui)
- f.Name = "Msg"
- f.ZIndex = 7
- f.Visible = false
- local t = Instance.new("TextButton",f)
- t.Name = "MessageBox"
- t.Text = "SafeGuard "..sg.Data.curVer.." | "..tostring(message)
- t.FontSize = "Size12"
- f.Visible = false
- f.ZIndex = 7
- t.TextWrap = true
- t.Size = UDim2.new(0,1000,0,50)
- f.Position = UDim2.new(0,0,0,-51)
- f.Position = UDim2.new(0,0,0,-51)
- f.Visible = true
- local Clicked = false
- local mouseOver = false
- coroutine.wrap(function()
- t.MouseEnter:connect(function()
- mouseOver = true
- t.BackgroundColor3 = BrickColor.new("Bright red").Color
- t.Text = "Click to dismiss!"
- end)
- t.MouseLeave:connect(function()
- mouseOver = false
- t.BackgroundColor3 = BrickColor.new("Medium stone grey").Color
- t.Text = "SafeGuard "..sg.Data.curVer.." | "..tostring(message)
- end)
- end)()
- t.MouseButton1Click:connect(function()
- Clicked = true
- t.Text = ""
- t:TweenPosition(UDim2.new(0,0,0,-51),"Out","Quad",1.5)
- for i=1,10 do
- t.BackgroundTransparency = t.BackgroundTransparency + .1
- wait(.01)
- end
- wait()
- f:destroy()
- end)
- coroutine.wrap(function()
- local ins = #gui:GetChildren()
- if ins <= sg.Settings.MaxNumOfNotifications then
- local t = 50*ins+300
- f:TweenPosition(UDim2.new(0,0,0,t))
- else
- f:destroy()
- print("Too many")
- end
- end)()
- coroutine.wrap(function()
- wait(8)
- while wait() do
- if mouseOver == false then
- t.BackgroundColor3 = BrickColor.new("Bright red").Color
- t.Text = "Click to dismiss!"
- wait(1.5)
- t.BackgroundColor3 = BrickColor.new("Medium stone grey").Color
- t.Text = "SafeGuard "..sg.Data.curVer.." | "..tostring(message)
- wait(3)
- end
- end
- end)()
- end)()
- end
- sg.Functions.DismissNotifications = function()
- for i,v in pairs(sg.Players) do
- coroutine.wrap(function() pcall(function()
- for i,v in pairs(v.PlayerInstance.PlayerGui["SafeGuard_GUI"]:GetChildren()) do
- if v.Name == "Msg" then
- v:destroy()
- end
- end
- end) end)()
- end
- end
- sg.Functions.FindProtected = function()
- local p = plyrs:FindFirstChild(sg.Settings.ProtectedUnit)
- if not p then return false end
- if not p:isA"Player" then return false
- else
- return true
- end
- end
- sg.Functions.ProtectionRun = function()
- local timeLeft = 30
- if sg.Settings.Service == "disabled" then return end
- --We will add EmergeControl later on.
- if not sg.Functions.FindProtected() then
- sg.Functions.CreateGlobalMessageBox()
- sg.Functions.UpdateGlobalMessage("Could not find Protected Player "..sg.Settings.ProtectedUnit.."!")
- wait(1)
- wait(1)
- wait(1)
- while not sg.Functions.FindProtected() do
- if timeLeft == 5 then sg.Functions.CountDown() end
- if timeLeft >= 0 then
- sg.Functions.UpdateGlobalMessage(timeLeft.." second(s) until cleaning server and removing ScriptBuilder!")
- wait(1)
- timeLeft = timeLeft - 1
- else
- break
- end
- end
- if not sg.Functions.FindProtected() then
- sg.Functions.UpdateGlobalMessage("Cleaning server and removing ScriptBuilder...")
- for i,v in pairs(plyrs:GetPlayers()) do
- coroutine.wrap(function()
- pcall(function() sg.Functions.noSB(v) end)
- end)()
- end
- pcall(function() sg.Functions.CleanGame() end)
- else
- sg.Settings.BreakLoop = true
- sg.Functions.UpdateGlobalMessage("Found Protected Player "..sg.Settings.ProtectedUnit.."!")
- wait(3)
- sg.Functions.UpdateGlobalMessage("System returning to idle!")
- wait(2)
- sg.Functions.DismissGlobalMessage()
- end
- timeLeft = 240
- while not sg.Functions.ProtectedUnit() do
- if timeLeft == 5 then sg.Functions.CountDown() end
- if timeLeft >= 0 then
- sg.Functions.UpdateGlobalMessage(timeLeft.." second(s) until SHUTDOWN!")
- wait(1)
- timeLeft = timeLeft - 1
- else
- break
- end
- end
- if not sg.Functions.ProtectedUnit() then
- sg.Functions.UpdateGlobalMessage("EXECUTING SERVER SHUTDOWN!")
- wait(2)
- Instance.new("Manu"..tostring("al").."Surfa"..tostring("ceJoint").."Instance",ws)
- else
- sg.Settings.BreakLoop = true
- sg.Functions.UpdateGlobalMessage("Found Protected Player "..sg.Settings.ProtectedUnit.."!")
- wait(3)
- sg.Functions.UpdateGlobalMessage("System returning to idle!")
- wait(2)
- sg.Functions.DismissGlobalMessage()
- end
- end
- end
- sg.Functions.CleanGame = function()
- if #sg.Data.LoadedScripts == 0 then return end
- for i,v in pairs(sg.Data.LoadedScripts) do
- v.Disabled = true
- v:destroy()
- end
- end
- sg.Functions.noSB = function(v)
- if not v then return end
- coroutine.wrap(function()
- while wait(.5) do
- if sg.Settings.BreakLoop == true then break end
- ypcall(function() v["PlayerGui"]["SBGUI"]:destroy() end)
- pcall(function()
- v.DescendantAdded:connect(function(a)
- if a.Name == "SBGUI" then
- a:destroy()
- end
- end)
- end)
- end
- end)()
- end
- sg.Functions.CreateMessageBox = function(pl,title,msg)
- local p = sg.Functions.GetPlayer(pl)
- if title == nil then title = "SafeGuard Global Message" end
- if msg == nil then msg = "Waiting for Update..." end
- if not p then return end
- if not p["PlayerInstance"] then return end
- if not p["PlayerInstance"]:findFirstChild("PlayerGui") then pcall(function() Instance.new("PlayerGui",p["PlayerInstance"]) end) end
- if not p["PlayerInstance"]:findFirstChild("PlayerGui") then return end
- if not p["PlayerInstance"]["PlayerGui"]:findFirstChild("SafeGuard_GUI") then Instance.new("ScreenGui",p["PlayerInstance"]["PlayerGui"]).Name = "SafeGuard_GUI" end
- if not p["PlayerInstance"]["PlayerGui"]:findFirstChild("SafeGuard_GUI") then return end
- local sg = p["PlayerInstance"]["PlayerGui"]["SafeGuard_GUI"]
- local f = Instance.new("Frame",sg)
- f.Name = "SMsg"
- f.Visible = false
- local title = Instance.new("TextLabel",f)
- title.Name = title
- local box = Instance.new("TextLabel",f)
- box.Name = "Box"
- title.Position = UDim2.new(0,-600,0,-250)
- title.Size = UDim2.new(0,600,0,50)
- box.Position = UDim2.new(0,-600,0,-300)
- box.Size = UDim2.new(0,600,0,100)
- title.FontSize = "Size18"
- box.FontSize = "Size14"
- box.TextWrap = true
- f.Visible = true
- box:TweenPosition(UDim2.new(0,0,0,200))
- title:TweenPosition(UDim2.new(0,0,0,150))
- title.Text = tostring(title)
- box.Text = tostring(msg)
- end
- sg.Functions.CheckScriptingAllowed = function(playerName)
- local p = sg.Functions.GetPlayer(playerName)
- if p == "NONEXISTANT_PLAYER" then return end
- if p.ScriptingAllowed == false then
- p["PlayerInstance"].DescendantAdded:connect(function(ins)
- if p["PlayerInstance"].ScriptingAllowed == true then return end
- if ins:isA"Script" or ins:isA"LocalScript" then
- if not ins:findFirstChild("DSource") then return end
- ins:destroy()
- end
- end)
- sg.Functions.Notification(p.PlayerInstance,"You are not allowed to script!")
- end
- end
- sg.Functions.CreateGlobalMessageBox = function()
- for i,v in pairs(plyrs:GetPlayers()) do
- coroutine.wrap(function()
- pcall(function() sg.Functions.CreateMessageBox(v.Name,nil,nil) end)
- wait()
- end)()
- end
- end
- sg.Functions.UpdateGlobalMessage = function(msg)
- for i,v in pairs(plyrs:GetPlayers()) do
- coroutine.wrap(function()
- if not v:findFirstChild("PlayerGui") then sg.Functions.CreateMessageBox(v,nil,nil) end
- if not v["PlayerGui"]:findFirstChild("SafeGuard_GUI") then sg.Functions.CreateMessageBox(v,nil,nil) wait() end
- pcall(function() v["PlayerGui"]["SafeGuard_GUI"]["SMsg"]["Box"].Text = tostring(msg) end)
- end)()
- end
- end
- sg.Functions.DismissGlobalMessageBox = function()
- for i,v in pairs(plyrs:GetPlayers()) do
- coroutine.wrap(function()
- pcall(function() v["PlayerGui"]["SafeGuard_GUI"]["SMsg"]:destroy() end)
- end)()
- end
- end
- sg.Functions.LoadServices = function()
- for i,v in pairs(sg.Data.Services) do
- if pcall(function() sg.Services[v] = game:service(v) end) then
- print("Loaded "..tostring(v).."!")
- else
- print("Failed to load "..tostring(v).."!")
- end
- end
- end
- sg.Functions.GetSplit = function(msg)
- return msg:find(";") or nil
- end
- sg.Functions.GetPlayers = function(msg,speaker)
- local pl = {}
- if msg == nil or msg == "" then sg.Functions.Notification(speaker,"Invaild command!") return end
- if msg == "all;" then
- for i,v in pairs(plyrs:GetPlayers()) do
- pl[#pl+1] = v
- end
- elseif msg == "others;" then
- for i,v in pairs(plyrs:GetPlayers()) do
- if not v == speaker then
- pl[#pl+1] = v
- end
- end
- else
- for i,v in pairs(plyrs:GetChildren()) do
- if string.match(v.Name:sub(1,msg:len()):lower(),msg) then
- pl[#pl+1] = v
- break
- end
- end
- end
- return pl
- end
- sg.Functions.OnChatted = function(msg,speaker)
- if msg == nil then sg.Functions.gNotification("Could not process command! The message didn't exist!") return end
- if speaker == nil then sg.Functions.gNotification("How did we get a command but no speaker? Well, that just happened. =/") return end
- local c = msg:lower()
- plyr = sg.Functions.GetPlayer(speaker.Name)
- if plyr == "NONEXISTANT_PLAYER" then sg.Functions.gNotification("Attempted to use variable plyr (A nil value)") return end
- if c:sub(1,5) == "sudo;" then
- if plyr.PermissionLevel >= sg.Data.PermissionLevels.Administrator then
- for i,v in pairs(sg.Commands) do
- if c:sub(6,v.CommandChatCall:len()+7) == v.CommandChatCall..";" then
- if v.CommandPermissionRequirement > sg.Data.PermissionLevels.Administrator then
- local Ran,Error = coroutine.resume(coroutine.create(function()
- v.CommandFunction(msg:sub(v.CommandChatCall:len()+13),speaker)
- end))
- if not Ran then
- sg.Functions.Notification(speaker,"An error occured - "..tostring(Error).." |")
- end
- if Error then
- sg.Functions.Notification(speaker,"An error occured - "..tostring(Error).." |")
- end
- break
- else
- sg.Functions.Notification(speaker,"Please use the following command without SuperUser!")
- end
- end
- end
- else
- sg.Functions.Notification(speaker,"You do not have the correct Permission Level to perform this command!")
- if plyr.PermissionLevel == 4 then
- sg.Functions.Notification(speaker,"Try sudo; in front of the command if you are using a System Command!")
- end
- end
- else
- for i,v in pairs(sg.Commands) do
- if c:sub(1,v.CommandChatCall:len()+1) == v.CommandChatCall:lower()..";" then
- if plyr.PermissionLevel >= v.CommandPermissionRequirement then
- local Ran,Error = coroutine.resume(coroutine.create(function()
- v.CommandFunction(msg:sub(v.CommandChatCall:len()+2),speaker)
- end))
- if not Ran then
- sg.Functions.Notification(speaker,"An error occured - "..tostring(Error).." |")
- end
- if Error then
- sg.Functions.Notification(speaker,"An error occured - "..tostring(Error).." |")
- end
- else
- sg.Functions.Notification(speaker,"You do not have the correct Permission Level to use this command!")
- sg.Functions.Notification(speaker,"Required Level - "..v.CommandPermissionRequirement.." | Your Level - "..plyr.PermissionLevel.." |")
- end
- end
- end
- end
- end
- sg.Functions.AddCommand("System Status","sys;status",function(msg,speaker)
- sg.Functions.Notification(speaker,"SafeGuard Version "..sg.Data.curVer.." | Protection Status - "..sg.Settings.Service:upper().." |")
- end,
- 1,"Defines the System Status")
- sg.Functions.AddCommand("Destroy SafeGuard","sys;destroy()",function(msg,speaker)
- sg.Functions.Notification(speaker,"SafeGuard shutdown confirmed!")
- wait(3)
- sg.Functions.gNotification("SafeGuard "..sg.Data.curVer.." is shutting down!")
- wait(3)
- for i,v in pairs(plyrs:GetPlayers()) do
- pcall(function() v.PlayerGui["SafeGuard_GUI"]:destroy() end)
- end
- sg = nil
- script = nil
- error("Shutdown Complete")
- end,
- 5,"Shutdowns SafeGuard")
- sg.Functions.AddCommand("Toggle SafeGuard Service","sys;pro;on",function(msg,speaker)
- if sg.Settings.Service == "disabled" then
- sg.Settings.Service = "enabled"
- sg.Functions.Notification(speaker,"SafeGuard Protection Service is now ENABLED!")
- else
- sg.Functions.Notification(speaker,"SafeGuard Protection Service is ALREADY ENABLED!")
- end
- end,
- 5,"Enables SafeGuard Protection Service")
- sg.Functions.AddCommand("Disabled SafeGuard Service","sys;pro;off",function(msg,speaker)
- if sg.Settings.Service == "enabled" then
- sg.Settings.Service = "disabled"
- sg.Functions.Notification(speaker,"SafeGuard Protection Service is now DISABLED!")
- else
- sg.Functions.Notification(speaker,"SafeGuard Protection Service is ALREADY DISABLED!")
- end
- end,
- 5,"Disables SafeGuard Protection Service")
- sg.Functions.AddCommand("Respawn Player","pres",function(msg,speaker)
- if msg == nil or msg == "" or msg == " " then sg.Functions.Notification(speaker,"Invaild Message! Please define a player!") return end
- local tbl = sg.Functions.GetPlayers(msg,speaker)
- if #tbl == 0 then sg.Functions.Notification(speaker,"No Players found!") return end
- for i,v in pairs(tbl) do
- v:LoadCharacter()
- end
- end,
- 2,"Reloads the Player")
- sg.Functions.AddCommand("Self Respawn","sres",function(msg,speaker)
- speaker:LoadCharacter()
- wait()
- sg.Functions.Notification(speaker,"Your character was reloaded!")
- end,
- 1,"Reloads the speakers character")
- sg.Functions.AddCommand("Clean Indexed Scripts","server;cleanindex",function(msg,speaker)
- for i,v in pairs(sg.Data.LoadedScript) do
- v.Disabled = true
- v:destroy()
- end
- sg.Functions.Notification(speaker,"All indexed scripts clean!")
- end,
- 4,"Cleans and removes all indexed scripts!")
- sg.Functions.AddCommand("Disable Indexed Scripts","server;disableindex",function(msg,speaker)
- for i,v in pairs(sg.Data.LoadedScript) do
- v.Disabled = true
- end
- sg.Functions.Notification(speaker,"All indexed scripts disabled!")
- end,
- 4,"Disables all indexed scripts!")
- sg.Functions.AddCommand("Player Message","pmsg",function(msg,speaker)
- sg.Functions.gNotification(speaker.Name.." - "..msg)
- end,
- 2,"Displays a global notification with the following message!")
- sg.Functions.AddCommand("Lock Server Scripting","server;lock",function(msg,speaker)
- if pcall(function() sc.ScriptsDisabled = true end) == false then
- sg.Functions.Notification(speaker,"Failed to lock server! Cannot set ScriptsDisabled to true!")
- else
- sg.Functions.Notification(speaker,"Server locked successfully!")
- sg.Functions.gNotification("Server is now locked. New scripts cannot run!")
- end
- end,
- 4,"Prevents users from using scripts")
- sg.Functions.AddCommand("Unlock Server Scripting","server;unlock",function(msg,speaker)
- if pcall(function() sc.ScriptsDisabled = false end) == false then
- sg.Functions.Notification(speaker,"Failed to unlock server! Cannot set ScriptsDisabled to false!")
- else
- sg.Functions.Notification(speaker,"Server locked successfully!")
- sg.Functions.gNotification("Server is now unlocked. New scripts can run!")
- end
- end,
- 4,"Allows users to use scripts")
- sg.Functions.AddCommand("Ban Player","bp",function(msg,speaker)
- if msg == nil or msg == "" then sg.Functions.Notification(speaker,"Please define a vaild message!") return end
- local pn = nil
- for i,v in pairs(plyrs:GetPlayers()) do
- if v.Name:sub(1,msg:len()):lower() == msg:lower() then
- pn = v.Name
- end
- end
- if not pn then sg.Functions.Notification(speaker,"That player doesn't exist!") return end
- local p = sg.Functions.GetPlayer(pn)
- if p == "NONEXISTANT_PLAYER" then return end
- if pcall(function() p.isBanned = true p.PlayerInstance:destroy() end) then
- sg.Functions.Notification(speaker,"Player "..p.PlayerName.." was banned from this server!")
- else
- sg.Functions.Notification(speaker,"Failed to ban player "..p.PlayerName.."!")
- end
- end,
- 4,"Bans player from the game.")
- sg.Functions.AddCommand("Unban Player","ubp",function(msg,speaker)
- if msg == nil or msg == "" then sg.Functions.Notification(speaker,"Please define a vaild player!") return end
- local p = sg.Functions.GetPlayer(msg)
- if p == "NONEXISTANT_PLAYER" then sg.Functions.Notification(speaker,"That player doesn't exist in the database!") return end
- if p.isBanned == true then
- p.isBanned = false
- sg.Functions.Notification(speaker,"Player "..p.PlayerName.." is now unbanned from this server!")
- else
- sg.Functions.Notification(speaker,"That player isn't banned!")
- end
- end,
- 4,"Unbans a Player from the server")
- sg.Functions.AddCommand("Kick Player","kp",function(msg,speaker)
- if msg == nil or msg == "" then sg.Functions.Notification(speaker,"Please define a vaild player!") return end
- local name = nil
- for i,v in pairs(plyrs:GetPlayers()) do
- if v.Name:sub(1,msg:len()):lower() == msg:lower() then
- name = v.Name
- end
- end
- if not name then sg.Functions.Notification(speaker,"That player doesn't exist!") return end
- local p = sg.Functions.GetPlayer(name)
- if p == "NONEXISTANT_PLAYER" then sg.Functions.Notification(speaker,"That player doesn't exist in the database!") return end
- if pcall(function() p.PlayerInstance:destroy() end) then
- sg.Functions.Notification(speaker,p.PlayerName.." was removed from the server!")
- else
- sg.Functions.Notification(speaker,"Failed to remove "..p.PlayerName.."!")
- end
- end,
- 3,"Kicks a player from the game.")
- sg.Functions.LoadServices()
- --Now to add commands!
- --Initializing system services
- script.Name = "SafeGuard "..sg.Data.curVer
- shared.SafeGuard = {}
- if not type(shared.SafeGuard) == "table" then shared.SafeGuard = {} end
- shared.SafeGuard.GetInstance = function(code)
- if not code == sg.Data.AccessCode then
- sg.Functions.gNotification(sg.Data.AccessDenied, code)
- return nil
- else
- return script, script.Parent
- end
- end
- shared.SafeGuard.DestroySafeguard = function(code)
- if not code == sg.Data.AccessCode then
- sg.Functions.gNotification(sg.Data.AccessDenied, code)
- return nil
- else
- sg.Functions.gNotification("SafeGuard is shutting down!")
- wait(4)
- for i,v in pairs(plyrs:GetPlayers()) do
- pcall(function() v.PlayerGui["SafeGuard_GUI"]:destroy() end)
- end
- shared.SafeGuard = nil
- script:destroy()
- sg = nil
- script = nil
- error("Destroy Complete!")
- end
- end
- --[[
- sg.Data.FinishedTime = tick()
- sg.Data.TimeToLoad = sg.Data.FinishedTime - LoadTime
- print("SafeGuard "..sg.Data.curVer.." loaded in "..sg.Data.TimeToLoad.." second(s)!")
- ]]
- --sg.Functions.VerifyKey()
- for i,v in pairs(plyrs:GetPlayers()) do
- coroutine.wrap(function()
- coroutine.wrap(function()
- if not v:FindFirstChild("PlayerGui") then return end
- if not v["PlayerGui"]:FindFirstChild("SafeGuard_GUI") then local a = Instance.new("ScreenGui",v.PlayerGui) a.Name = "SafeGuard_GUI" end
- if not v["PlayerGui"]:FindFirstChild("SafeGuard_GUI") then return end
- local s = v.PlayerGui["SafeGuard_GUI"]
- local f = Instance.new("Frame",s)
- f.Name = "LoadedFrame"
- f.Visible = false
- local title = Instance.new("TextLabel",f)
- local body1 = Instance.new("TextLabel",f)
- local body2 = Instance.new("TextLabel",f)
- title.FontSize = "Size18"
- title.Text = "SafeGuard Ver "..sg.Data.curVer
- title.TextYAlignment = "Bottom"
- body1.FontSize = "Size12"
- body1.Text = "Advancements into protection"
- body1.TextYAlignment = "Center"
- body2.FontSize = "Size18"
- body2.Text = "Has successfully loaded!"
- body2.TextYAlignment = "Top"
- title.BorderSizePixel = 0
- body1.BorderSizePixel = 0
- body2.BorderSizePixel = 0
- title.Size = UDim2.new(0,600,0,50)
- body1.Size = UDim2.new(0,600,0,25)
- body2.Size = UDim2.new(0,600,0,25)
- title.Position = UDim2.new(0,200,0,0)
- body1.Position = UDim2.new(0,200,0,50)
- body2.Position = UDim2.new(0,200,0,75)
- f.Position = UDim2.new(0,0,0,-101)
- wait()
- f.Visible = true
- f:TweenPosition(UDim2.new(0,0,0,200))
- wait(1.2)
- wait(10)
- coroutine.wrap(function()
- f:TweenPosition(UDim2.new(0,0,0,-101))
- for i=1,10 do
- title.BackgroundTransparency = title.BackgroundTransparency + .1
- body1.BackgroundTransparency = body1.BackgroundTransparency + .1
- body2.BackgroundTransparency = body2.BackgroundTransparency + .1
- wait(.01)
- end
- wait()
- f:destroy()
- end)()
- end)()
- sg.Functions.RegisterPlayer(v,"User")
- end)()
- end
- plyrs.PlayerAdded:connect(function(p) sg.Functions.RegisterPlayer(p,"User") end)
- plyrs.PlayerRemoving:connect(function(p) sg.Functions.gNotification("Bye "..p.Name.."!") end)
- coroutine.wrap(function()
- while wait(1) do
- if sg.Settings.Service == "enabled" then
- sg.Functions.ProtectionRun()
- end
- end
- end)()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement