this is why i don’t suggest using setfenv. Setfenv replaces the entire environment of a script or a function, this includes the setfenv global and print global. You can try doing this
local env = getfenv()
env['doThis'] = module.doThis
setfenv(1, env)
if that doesn’t work you’ll have to manually assign each globals name to itself again, I have that here though
return {
["_G"] = _G,
["assert"] = assert,
["Axes"] = Axes,
["BrickColor"] = BrickColor,
["bit32"] = bit32,
["buffer"] = buffer,
["CFrame"] = CFrame,
["Color3"] = Color3,
["coroutine"] = coroutine,
["CatalogSearchParams"] = CatalogSearchParams,
["ColorSequenceKeypoint"] = ColorSequenceKeypoint,
["ColorSequence"] = ColorSequence,
["collectgarbage"] = collectgarbage,
["delay"] = delay,
["debug"] = debug,
["DateTime"] = DateTime,
["DockWidgetPluginGuiInfo"] = DockWidgetPluginGuiInfo,
["Delay"] = Delay,
["error"] = error,
["Enum"] = Enum,
["ElapsedTime"] = ElapsedTime,
["elapsedTime"] = elapsedTime,
["Font"] = Font,
["File"] = File,
["Faces"] = Faces,
["FloatCurveKey"] = FloatCurveKey,
["game"] = game,
["getfenv"] = getfenv,
["getmetatable"] = getmetatable,
["gcinfo"] = gcinfo,
["Game"] = Game,
["Instance"] = Instance,
["ipairs"] = ipairs,
["loadstring"] = loadstring,
["math"] = math,
["newproxy"] = newproxy,
["NumberRange"] = NumberRange,
["NumberSequenceKeypoint"] = NumberSequenceKeypoint,
["next"] = next,
["NumberSequence"] = NumberSequence,
["OverlapParams"] = OverlapParams,
["os"] = os,
["plugin"] = plugin,
["print"] = print,
["pcall"] = pcall,
["pairs"] = pairs,
["PhysicalProperties"] = PhysicalProperties,
["PathWaypoint"] = PathWaypoint,
["printidentity"] = printidentity,
["require"] = require,
["Random"] = Random,
["rawget"] = rawget,
["RaycastParams"] = RaycastParams,
["RotationCurveKey"] = RotationCurveKey,
["rawset"] = rawset,
["rawequal"] = rawequal,
["Rect"] = Rect,
["rawlen"] = rawlen,
["Ray"] = Ray,
["Region3"] = Region3,
["Region3int16"] = Region3int16,
["select"] = select,
["shared"] = shared,
["string"] = string,
["spawn"] = spawn,
["setmetatable"] = setmetatable,
["setfenv"] = setfenv,
["Secret"] = Secret,
["settings"] = settings,
["SharedTable"] = SharedTable,
["stats"] = stats,
["Stats"] = Stats,
["Spawn"] = Spawn,
["table"] = table,
["TweenInfo"] = TweenInfo,
["tostring"] = tostring,
["type"] = type,
["tonumber"] = tonumber,
["tick"] = tick,
["task"] = task,
["typeof"] = typeof,
["time"] = time,
["UDim2"] = UDim2,
["unpack"] = unpack,
["utf8"] = utf8,
["UDim"] = UDim,
["UserSettings"] = UserSettings,
["Vector3"] = Vector3,
["Vector"] = Vector2,
["Vector3int16"] = Vector3int16,
["Vector2int16"] = Vector2int16,
["Version"] = Version,
["version"] = version,
["workspace"] = workspace,
["wait"] = wait,
["warn"] = warn,
["Wait"] = Wait,
["Workspace"] = Workspace,
["xpcall"] = xpcall,
["ypcall"] = ypcall,
}