Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is it good idea to parent script to the game?

I have made custom module for replacing the TweenService, now i want to access it and i got a very cool idea to make it very easily accessible from multiple scripts, i want it because i want to feel like it is the real service and real services you don't get them like this:

local tweenService = replicatedStorage.modules.container.otherstuff.......

But like this:

local tweenService = game:GetService("TweenService")

So my shorter idea was to parent it to the game

script.Parent = game

I could create module which would do that in studio as you can't parent it to the game in explorer but the question is, is it good idea or should i forget about it, no, trash idea?

Thanks, kirda

1 comment

1

Why would you want that? Serverscriptservice is good enough!

1 answer

✓ Accepted answer

I would not, the game object is basically the whole game in example.

game.Players

We are using that game object to get the Players Service. I would either use Workspace or SeverScriptService (For a sever script)

(After reading your question more)

You can just put the module script into SeverScriptStorage.

To access the module script,

local SeverScriptService = game:GetService("SeverScriptService") 
local ModuleScript = require(SeverScriptService.TweenModule) 

Sources https://developer.roblox.com/en-us/articles/modulescripts https://developer.roblox.com/en-us/api-reference/function/ServiceProvider/GetService

Skippy

2 comments

0

Please upvote and accept this as the answer, this helps other users find it more quickly.

0

*If it answers the question ^ *

This discussion is preserved as it was. New answers, comments, and votes are closed.