You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to make a plugin that erases all scripts that only say “Hello, World!”
What is the issue? Include screenshots / videos if possible!
I do not know how and where to start.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried to do it manually but there are thousands of them, I have looked at solutions in the dev hub but found nothing.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I do not have any further details, I just need support with this issue
-- This is an example Lua code block
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
If you have a subtle knowledge about creating plugins, I could go with explaining how to delete those intended scripts at the moment.
You have to delete the scripts writing print("Hello world!"), right? Let’s create a button inside the plugin interface and a bind function to run after clicking.
local function onClick()
-- Anything
end
button.Activated:Connect(onClick)
The function onClick will be used whenever the button is clicked. Now we have to determine scripts that contain the phrase. Iterate over the data model to reference all the scripts.
for _, scr in pairs(game:GetDescendants()) do
if scr:IsA("LuaSourceContainer") then
end
end
But we need to include the ones having the phrase, so decide on one string pattern to check whether the scripts own this pattern.
for _, scr in pairs(game:GetDescendants()) do
if scr:IsA("LuaSourceContainer") then
if string.match(scr.Source, '^print%("Hello world!"%)$') then
print("Found hello world")
end
end
end
This pattern ^print%("Hello world!"%)$ will tell you whether the script matches only this phrase. It’ll fail if the script contains any other characters like 8, k, etc.
Eventually, destroy the scripts after the correct match. I added the print function; you may desire the directory of the script.
local function onClick()
for _, scr in pairs(game:GetDescendants()) do
if scr:IsA("LuaSourceContainer") then
if string.match(scr.Source, '^print%("Hello world!"%)$') then
print(scr:GetFullName())
scr:Destroy()
end
end
end
end
button.Activated:Connect(onClick)