local Script = {
new = function()
return { Name = "Script", Parent = nil, Source = [[print("Hello, world")]],
run = function(self)
if self.Parent ~= nil then
coroutine.wrap(function()
getfenv()["script"] = self
loadstring(self.Source)()
end)()
end
end,
copy = function(self)
return { Name = self.Name, Parent = nil, Source = self.Source, run = self.run, copy = self.copy, delete = self.delete }
end,
delete = function(self)
self = nil
end }
end
}
--Use
local S = Script.new()
S.Parent = workspace
S.Source = [===[
--Source here! This is your script.
]===]
--To run the script:
S:run()
--To copy the script:
S:copy()
--To delete the script:
S:delete() |