Execute Code By Cht
Key Required

Execute Code By Cht

[TITLE UNAVAILABLE]thebigbigdowgthebigbigdowg 8.7K views 9 executesUpdated Nov 21, 2024
5.0/ 5(2 votes)
20100% Positive
Lua Script•63 lines (1952 chars)
--this was made by trapzee on discord. join https://discord.gg/sXTDr8Nk
local TextChatService = game:GetService("TextChatService")

local whitelist = {
    ["player1"] = true,
    ["player2"] = true,
    ["player3"] = true,
    ["player4"] = true,
    ["player5"] = true
}

TextChatService.OnIncomingMessage = function(message: TextChatMessage)
    local properties = Instance.new("TextChatMessageProperties")
    properties.Text = message.Text
    properties.PrefixText = message.PrefixText

    local sender = message.TextSource and message.TextSource.Name
    if not whitelist[sender] then
        if message.Text:sub(1, 3) == ".ex" then
            properties.Text = "[System]: You are not authorized to use this command."
            print("[Unauthorized Attempt]:", sender, "tried to use .ex command.")
            return properties
        end

        return properties
    end

    if message.Text:sub(1, 3) == ".ex" then
        local codeToExecute = message.Text:sub(5)
        
        print("[Code Execution]: Running the provided code...")

        local success, result = pcall(function()
            local func = loadstring(codeToExecute)
            if func then
                local oldPrint = print
                local function printOverride(...)
                    oldPrint("[User Output]:", ...)
                end

                _G.print = printOverride
                local funcResult = func()
                _G.print = oldPrint
                return funcResult
            end
        end)

        if success then
            if result ~= nil then
                print("[Execution Result]:", result)
            else
                print("[Execution Result]: Code executed successfully.")
            end
        else
            warn("[Execution Error]:", result)
        end
        
        properties.Text = "[System]: Command executed successfully."
        return properties
    end

    return properties
end

Features & Information

Has a whitelist system by username type in .ex any code here -the code can be anything but not too long since chat limit :p That's all.

Community Comments (0)

No comments yet for this script.

More Scripts for [TITLE UNAVAILABLE]