Custom Service Creator V1

Hey there so recently I was kinda annoyed the fact that there could be so many things I could do if I could create my own service e.g make a npc creater service or make a tycoon service. So I looked around and found what I think would be a good way to do it. The code is pretty simple and has probably been used loads before but it uses this: Making your own methods for Instances and some _G stuff which I know is probably not the best but it is all I could think of to
make it more accessible.

Any feedback or comments is appreciated

Getting Started

So all you need to do is get the module script here and put it anywhere you like although it is recommended you put it in ServerStorage. After in any script type the line: require(path to script):Start() right and so now it should work anywhere (apart from local scripts)

Making my own service

Right so now that you have it loaded you can call it by doing _G.Servicer and we want to use the :CreateService() function and it takes 2 parameters first is the name of the service and the second is a module script which we can attach to it. I’m gonna call mine Jeffrey cause why not and just use the DataStore2 module script so _G.Servicer:CreateService("Jeffrey",script.Parent.Ds2) and there we go we now have a custom service.

Using the service

Now you maybe wondering is there a special function to get it and the answer is no. All you have to do is call _G.Servicer:GetService(service name) and yes it does work with already in game services e.g players.
I am just going to call mine and store it as a variable so local Ds2 = _G.Servicer:GetService("Jeffrey") and now we have the DataStore2 module in our code meaning I can call Ds2:Save() or Ds2:Set() although keep in mind it will not autofill which is a downside.

There maybe optimization’s and small things I could do to make it better because it is in BETA and it does not have proper anticheat to stop a hacker from accessing it but that will be coming in future updates

The End

So I hope you find this module useful and easy to use and if you have any questions please reply with them and do the same for bugs. :slight_smile: thanks for reading

If you found this module useful donating 2 or 3 robux to this link would be very appreciated: PlsDonateLink

3 Likes

Pretty good, may we have this as a Plug-In?

1 Like

will try to make one but working with the ui gets confusing

Yes sit can be, but in the end it’s not that hard

Is there a way to make that service work on server scripts only?

It already does if you put it in server storage. No local script can access it as if you start it on a server script then _G is only working on server side. You can test it if you want

1 Like

Apart from what @hya123456h said a simple check with :IsA should do the.m trick

Why does it use _G? It is a bad practice, I tried that and it returned nil

I know _G is bad practice but it is the only way I could think of making it accessible for any script and it adds in that real service feel. Also _G will return nil until you set something in it I think.

You could use ModuleScripts, they are made to replace _G

1 Like

I was thinking about that but if you had it in a folder really deep somewhere it would be a pain having to require it and much better to just require the linked ModuleScript directly

This could be very useful for some projects and is easy to use. Good job

Answer:
Don’t keep it deep within a Folder

(Maybe you create a Folder to put all of the ModuleScripts for the Services)

1 Like

Trying to get everyone to do that would be impossible especially if you want it to be really organized.

1 Like