ADVERTISEMENTREMOVE ADS

Execute code by chat

Universal script
9 months ago
Script preview thumbnail
Script Preview

Description

to use, the user executes the script which means the whitelisted people can execute code using the chat.

the whitelisted user types in chat to execute the script for example

".ex game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 45"

and the speed will effect the user who has executed the script.

BUT always type ".ex" or the code in chat will not work

ADVERTISEMENTREMOVE ADS
63 Lines • 1.97 KiB
Raw
--this was made by trapzee on discord. join https://discord.gg/w45NarMG
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
ADVERTISEMENTREMOVE ADS

Comments

0 comments
to add a comment
Loading comments
ADVERTISEMENTREMOVE ADS