Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local loadtime = tick()
- -- Welcome to Tohru's GSE (Global Script Executer)
- -- Essentially, this script will allow for other people in your lobby to execute scripts via your client
- -- This does not have protection so be careful who you whitelist for your script!
- -- Example(Player: ;run [script] Script will not run because player is not whitelisted)
- -- (You: ;whitelist Player|Player: ;run [script] Script will now run because player is now whitelisted)
- local Version = '1.0'
- local Players = game:GetService("Players")
- _G.ran = false
- local LP = Players.LocalPlayer
- function has(sample, text)
- sample = sample or "Sample Text"
- text = text or "Sample"
- if (string.match(sample, text) and true or false) then
- return true
- else
- return false
- end
- end
- function genlog(user, whitelist, code)
- return "LOG|User: "..tostring(user).."|Whitelisted? "..tostring(whitelist).."|Input: [' "..tostring(code).." ']|Time: "..currenttime().."|"
- end
- function findplayer(input)
- input = tostring(input)
- local matched_players = {}
- for i,v in pairs(game:GetService("Players"):GetPlayers()) do
- if input == "all" then
- table.insert(matched_players, v)
- elseif input == "others" then
- if v.Name ~= game:GetService("Players").LocalPlayer.Name then
- table.insert(matched_players, v)
- end
- elseif input == "me" then
- if v.Name == game:GetService("Players").LocalPlayer.Name then
- table.insert(matched_players, v)
- end
- else
- if string.sub(string.lower(v.Name),1,#input) == string.lower(input) then
- table.insert(matched_players, v)
- end
- end
- end
- if #matched_players ~= 0 then
- return matched_players else return false
- end
- end
- function SendMsg(String)
- String = tostring(String) or "Hello!"
- game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents.SayMessageRequest:FireServer(String, "all")
- end
- function Notify(Text)
- Text = Text or "Return: nil"
- game.StarterGui:SetCore("SendNotification", {Title = "Tohru GSE"; Text = Text})
- end
- function split(text, divider)
- local seperated = {}
- for i in text:gmatch("[^".. divider .."]+") do
- table.insert(seperated,i)
- end
- return seperated
- end
- function runscript(code)
- _G.ran = true
- code = tostring(code)
- loadstring(code)()
- _G.ran = false
- end
- function stringify(t)
- ta = {}
- for i,v in pairs(t) do
- if i ~= #t then
- table.insert(ta, t[i]..", ")
- else
- table.insert(ta, t[i])
- end
- end
- return table.concat(ta)
- end
- function currenttime()
- the_hour = math.floor((tick() % 86400) / 3600)
- the_minute = math.floor((tick() % 3600) / 60)
- the_second = math.floor(tick() % 60)
- the_time_of_day = the_hour > 11 and 'PM' or 'AM'
- the_hour = (the_hour % 12 == 0 and 12 or the_hour % 12)
- the_hour = the_hour < 10 and '0' .. the_hour or the_hour
- the_minute = the_minute < 10 and '0' .. the_minute or the_minute
- the_second = the_second < 10 and '0' .. the_second or the_second
- return the_hour .. ':' .. the_minute .. ':' .. the_second .. ' ' .. the_time_of_day
- end
- local old1
- local function hook1(p)
- if _G.ran then
- SendMsg("OP {P}: "..tostring(p))
- end
- return old1(tostring(p))
- end
- old1 = hookfunction(print, hook1)
- local old2
- local function hook2(w)
- if _G.ran then
- if #split(tostring(w), ":") > 2 then
- wrn = split(tostring(w), ":")
- warnline = wrn[2]
- warnmsg = wrn[3]
- SendMsg("OP {W @ Line "..warnline.."}:"..warnmsg)
- else
- SendMsg("OP {W}: "..tostring(w))
- end
- end
- return old2(tostring(w))
- end
- old2 = hookfunction(warn, hook2)
- game:GetService("ScriptContext").Error:Connect(function(fail)
- if _G.ran then
- if #split(tostring(fail), ":") > 2 then
- failer = split(tostring(fail), ":")
- errline = failer[2]
- errmsg = failer[3]
- SendMsg("OP {E @ Line "..errline.."}:"..errmsg)
- else
- SendMsg("OP {E}: "..tostring(fail))
- end
- end
- end)
- WL = {Players.LocalPlayer.Name}
- whitelist_logs = {}
- script_logs = {}
- prefix = ";"
- function cmdcheck(input, cmd, checktype)
- if checktype == "multiple" or checktype == "m" then
- if has(input:lower(), prefix..""..cmd.." ") and input:sub(1,1) == prefix and input:sub(2, (cmd):len() + 1) == cmd then
- return true else return false
- end
- elseif checktype == "single" or checktype == "s" then
- if input == prefix..""..cmd then
- return true else return false
- end
- end
- end
- function getargs(input, cmd)
- return input:sub(prefix:len() + cmd:len() + 2 )
- end
- local Users = Instance.new("Folder")
- local Players = game:GetService("Players")
- local CoreGui = game:GetService("CoreGui")
- Users.Name = "GSE Users"
- Users.Parent = CoreGui
- Users.ChildAdded:Connect(function(child)
- wait(0.1)
- for i,v in ipairs(Users:GetChildren()) do
- if v.Name == child.Name then
- v:Destroy()
- end
- end
- Players[child.Name].Chatted:Connect(function(msg)
- if cmdcheck(msg, "whitelist", 'm') then
- if tostring(Players[child.Name]) == tostring(LP.Name) then
- msg = getargs(msg, "whitelist")
- placeholder1 = {}
- placeholder2 = {}
- placeholder3 = {}
- for i,v in pairs( split(msg, ", ") ) do
- if findplayer(v) then
- for a, b in pairs(findplayer(v)) do
- if b.Name ~= LP.Name then
- table.insert(placeholder1, b.Name)
- end
- end
- elseif not findplayer(v) then
- table.insert(placeholder2, tostring(v))
- end
- end
- for i,v in pairs(placeholder1) do
- for h,j in pairs(WL) do
- if v == j then
- table.insert(placeholder3, v)
- placeholder1[i] = nil
- end
- end
- end
- for i,v in pairs(placeholder1) do
- table.insert(WL, tostring(v))
- end
- if #placeholder1 ~= 0 then
- Notify("Whitelisted: ".. stringify(placeholder1))
- table.insert(whitelist_logs, "LOG|Whitelisted '".. stringify(placeholder1) .."' at ".. currenttime())
- end
- if #placeholder2 ~= 0 then
- Notify("Failed to find '"..stringify(placeholder2).."'!")
- end
- if #placeholder3 ~= 0 then
- Notify('"'.. stringify(placeholder3) ..'" is already whitelisted!')
- end
- end
- end
- if cmdcheck(msg, "whitelisted", 's') then
- if tostring(Players[child.Name]) == tostring(LP.Name) then
- Notify("Whitelisted : ".. stringify(WL))
- print('[-----[WHITELISTED USERS #'.. #WL ..']-----]')
- for i,v in pairs(WL) do
- print(v)
- end
- print('[-----[WHITELISTED USERS #'.. #WL ..']-----]')
- end
- end
- if cmdcheck(msg, "blacklist", 'm') then
- if tostring(Players[child.Name]) == tostring(LP.Name) then
- msg = getargs(msg, "blacklist")
- if msg == "all" or msg == "others" then
- for i = 1, #WL do
- if WL[i] ~= LP.Name then
- WL[i] = nil
- end
- end
- table.insert(whitelist_logs, "LOG|Cleared Whitelist table at ".. currenttime())
- Notify("Cleared Whitelist Table")
- else
- placeholder1 = {}
- placeholder2 = {}
- for i, v in pairs( split(msg, ", ") ) do
- for a, b in pairs(WL) do
- if b ~= LP.Name then
- if string.sub(string.lower(b), 1, #msg) == string.lower(msg) then
- table.insert(placeholder1, b)
- else
- table.insert(placeholder2, v)
- end
- end
- end
- end
- if #placeholder1 ~= 0 then
- for i,v in pairs(placeholder1) do
- for a = 1, #WL do
- if v == WL[a] then
- WL[a] = nil
- end
- end
- end
- Notify("Blacklisted : ".. stringify(placeholder1))
- table.insert(whitelist_logs, "LOG|Blacklisted '".. stringify(placeholder1) .."' at ".. currenttime())
- end
- if #placeholder2 ~= 0 then
- Notify("Failed to find '".. stringify(placeholder2) .."'!")
- end
- end
- end
- end
- if cmdcheck(msg, "s", "m") then
- WL_Check = 'false'
- msg = getargs(msg, "s")
- for i,v in pairs(WL) do
- if tostring(Players[child.Name]) == v then
- spawn (function()
- wait()
- runscript(tostring(msg))
- end)
- WL_Check = 'true'
- else
- WL_Check = "false"
- end
- end
- table.insert(script_logs, genlog(tostring( Players[child.Name] ), WL_Check, tostring(msg) ))
- end
- if cmdcheck(msg, "logs", "s") then
- if tostring(Players[child.Name]) == tostring(LP.Name) then
- if #script_logs == 0 and #whitelist_logs == 0 then
- Notify("No logs found!")
- else
- Notify("Script Logs: #".. #script_logs .."|Whitelist Logs: #".. #whitelist_logs .."|Total Logs: #".. #script_logs + #whitelist_logs .."")
- print("[-----[WHITELIST LOGS #".. #whitelist_logs .."]-----]")
- for i,v in pairs(whitelist_logs) do
- print(v)
- end
- print("[-----[WHITELIST LOGS #".. #whitelist_logs .."]-----]")
- print("[-----[SCRIPT LOGS #".. #script_logs .."]-----]")
- for i,v in pairs(script_logs) do
- print(v)
- end
- print("[-----[SCRIPT LOGS #".. #script_logs .."]-----]")
- end
- end
- end
- end)
- end)
- for i = 1, #Players:GetPlayers() do
- Instance.new("BoolValue", Users).Name = Players:GetPlayers()[i].Name
- end
- Players.PlayerAdded:Connect(function(plr)
- Instance.new("BoolValue", Users).Name = plr.Name
- end)
- Players.PlayerRemoving:Connect(function(plr)
- for i = 1, #Users:GetChildren() do
- if Users:GetChildren()[i].Name == plr.Name then
- Users:GetChildren()[i]:Destroy()
- end
- end
- end)
- Notify("Tohru GSE "..Version.." ran successfully!")
- print("Tohru GSE Version ["..Version.."] | LoadTime [".. tick() - loadtime .."]")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement