Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
4

Is it not recommended to use separate scripts for different purposes?

Asked by 6 years ago
Edited 6 years ago

I come from Unity 3D, where it's encouraged to use different scripts for different purposes. Such as one script may handle game mechanics, one may handle user's stats, etc. In this environment, you can access members and properties of different classes, but I'm seeing that the only way to do this in Roblox/Lua is with modules or something similar.

Therefore, my question is, should I handle most, if not all, of my server actions in a single script? How am I expected to access members of one script from another? Do most people just slap on some IntValues, ObjectValues, etc. and read from those? Is this not exposing the client to potential exploits?

I'm very new to Roblox's coding environment, so I hope you understand where I'm coming from, it's just strange to feel as if it's limited in the sense that there isn't much access between different components

Thanks

0
I feel the more instance values you add. The clunkier and more hacky your code becomes. Griffi0n 315 — 6y
0
Thanks Griffi0n, what do most people do then? I don't feel like most of these projects are built with 5000 line server scripts! Firedan1176 29 — 6y
0
I don't think you are able to do all (or most) of your code in one server script(due to network filtering, you must communicate between the server and client and vice versa based off of your game code). For example, you have a touched event, would you rather do that in a separate server script or would you rather put it in a server script containing all of your game logic. saSlol2436 716 — 6y
0
saSlol2436 I understand that, but what I don't understand is how am I supposed to communicate with other scripts when Roblox doesn't give you the option to call functions on other scripts without using _G or modules? Firedan1176 29 — 6y
View all comments (2 more)
0
I think what you are referring to other script without using _G or modules is like a public variable, public class or public function etc. The only option you can pretty much use are _G,shared,BindableEvents and/or BindableFunctions, or module scripts to communicate between scripts. saSlol2436 716 — 6y
0
We can discuss via scripting helpers chat @Firedan1176 saSlol2436 716 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

Depends what said "Different Purposes" are.If it would work best with script.Parent rather than game.Workspace.Model.Model.Model.Model.Thruster, than yeah it's recommended. But if it's something like purchases handling and leaderstat setup, than no. I would recommend using things to do similar things in one script. Other than that, do it in multiple scripts.

In general, if they are related, then yes. If they are unrelated purposes, than no.

As for the values, yes. Just make sure to do some anti-hack scripts. I can type one out if you need it. But, you need a bool value and another value, which most hackers won't see through right then and there. So, basically, yes, most people just slap on some IntValues, ObjectValues, etc. and read from those. ALSO: You have to use values for stuff like leaderstat values (the stats that are up on the player view menu). You also gatta either keep the leaderstats folder/value stored or use Instance.new for each member of the leaderstats stuff.

Ad

Answer this question