Ever wanted to create your own service and use it with easy ‘game.Service’ syntax?(i don’t know if anyone actually wanted to do so lol) Well now you can!
It has easy use syntax, you have 2 functions, Mimic and Load(both have “:” syntax)
To create a service use local MimicService = require(yourpathtomodule) local module = game.ReplicatedStorage.ModuleScript MimicService:Mimic("Service Name", module)
This creates a fake service, to load ALL services you created, use
local MimicService = require(yourpathtomodule) MimicService:Load()
This will load in all of the services you created and let you use them with game.Service syntax.
P.s: This module has some flaws, it can quite greatly affect code’s optimization(as it uses getfenv, which is often a bad practice). Please give your feedback and ideas on how to improve this! Thanks. MimicService.rbxm (1.0 KB)
Edit: Added some functions like GetService, FindFirstChild, etc. Also optimized the code a bit
Edit 2: i have made a new module called Unlocker, it is way better than MimicService, it is way easier to use, it has all of its functional along with alot of other things.
Other than that, the use of getfenv here is really unavoidable if you want to override the game global
Heres an improved version I’ve made myself, use it if u want :V :
local MimicModule = {}
local DataModel = setmetatable({}, {__index = game})
function MimicModule.mimic(name: string, module: ModuleScript)
DataModel[name] = require(module)
end
function MimicModule.load()
getfenv(2).game = DataModel
end
return MimicModule
Some improvements to make:
Maybe just make it used like this:
local game = require(MimicService)
So it’s more of a mock DataModel, and just have a method like MimicService:AddService(), since modulescripts are cached it’ll be visible to other scripts/modules too, this way you don’t have to use getfenv
oh damn, thank you so much lol. i absolutely forgot that i dont need to create an instance.
also i concatenate an empty string to turn into a string, if it isnt one, but now looking yeah it was a dumb idea. also metatable way is so much cleaner than my original, again thank you!
Also you might wanna override GetService, FindService and all the FindFirstChild methods so they can also search for the “virtual” services (Just put them inside the DataModel table so they override the __index metamethod)
i mean yeah, but this makes it much more easy to organize. like you create services in different scripts and you can load them in another script for example. so you dont need to type require alot of times.
You still need to require MimicService tho, so what’s the difference? I may as well just require all of my modules in another module, that’d be the same thing. It’d be funny if you didn’t have to do that, but you do.
you require only one module, and all other services load in. you can create even like 10 services and still be able to load in all of them with one line.
it practically is a module loader, but in a fancier wrapping. right now im working on module called ‘Unlocker’ which will be lot more useful than mimicservice. MimicService will migrate into it and undergo some changes.
Unlocker is a module that as the name states, unlocks certain stuff that is blocked in regular roblox lua. Like game:GetObjects() and quite a bit more. I will create another post and link it there after i finish unlocker!
Edit: so yeah practically mimicservice is discontinued ig