So right now I’m writing what is my first and probably my last plugin, It is supposed to change the scripts starting test to "print(“Hello world!”) to something else.
The error I am getting is:
My Code:
game.DescendantAdded:Connect(function(desc)
if desc:IsA("Script") then
if desc.Source == 'print("Hello world!")' or desc.Source == 'print("Hello World!")' or desc.Source == "print('Hello world!')" then
desc.Source = [[-- File:
-- Author: wayIxn
-- Description:
--// Services
--// Variables
--// Functions
--// Other
]]
end
end
end)
It is worth noting that when I run the script in the command bar it does not work, and I published it in a LocalScript in Workspace.
pcall(function()
game.DescendantAdded:Connect(function(desc)
if desc:IsA("Script") then
if desc.Source == 'print("Hello world!")' or desc.Source == 'print("Hello World!")' or desc.Source == "print('Hello world!')" then
desc.Source = [[-- File:
-- Author: wayIxn
-- Description:
--// Services
--// Variables
--// Functions
--// Other
]]
end
end
end)
end)
That seemed to have worked, but now my script doesnt work, It didn’t in the first place either. I’m not great with plugins so I’m not sure how to fix that either.
game.DescendantAdded:Connect(function(desc)
local s, e = pcall(function()
if desc:IsA("Script") then
if desc.Source == 'print("Hello world!")' or desc.Source == 'print("Hello World!")' or desc.Source == "print('Hello world!')" then
desc.Source = [[-- File:
-- Author: wayIxn
-- Description:
--// Services
--// Variables
--// Functions
--// Other
]]
end
end
end)
end)
About to see if there are errors in the pcall, though.
game.DescendantAdded:Connect(function(desc)
local s, e = pcall(function()
if desc:IsA("Script") then
if tostring(desc.Source) == 'print("Hello world!")' then -- those diffrent types of print are unneeded, I think that studio only uses print("Hello World!"), correct me here if I am wrong.
desc.Source = [[-- File:
-- Author: wayIxn
-- Description:
--// Services
--// Variables
--// Functions
--// Other
]]
end
end
end)
end)