I cant improve at scripting

Their are multiple ways to utilize modules. Also modularity and very good for managing large chunks of data to reduce the lua heap size. Say you have a module with text data inside it. Even if that function is not called it still is in ram and has the text data, you modularize the text data and now the cache can be called on demand instead of holding it in memory. Also say you have a method for something that is mechanically a part of your game wether it be a gate to a touch connection or an established mechanic such as facing a target, standard interactions need standard functions that are shared across the entire project. These can be very small, you do not need to load a module everytime you use it, you can load it once and use create a bindable function.
For example, I have an AI in my game that has weights thats are about 76mb in size. It handles text processing and text display, I can Invoke it from anywhere in any script.

Just did an optimization to a randomquest generator algorithm storying all the text data in modules and requiring them in real time, the performance is much improved and so is the memory management. No one in there right mind who is an experienced programmer worth a dime would write everything from scratch.

Why do i hear so many excuses and 0 examples, and, moreover, I see the giant boulder of performance loss your technique is carrying.

1 Like

there is no universe where wrinting your function 100 times is better practice in terms of memory usage or performance than loading a function via a module as a local variable. The two methods; one your have 100 times more text and you intend to maintain all 100 copies. Again you are spouting falsities and I don’t understand why you are arguing.

you making excuses… ‘A function on top for it to be reachable for code below?’ You making sense bub you got big rain? you spout nonsesne and make no sense.
I encourage you to read up on module scripts instead of thinking you know what you are talking about when you are a nothing but a troll.

Some importants takeaways are.
"As projects become complex, it becomes important to think how scripts are organized. Good organization practices can ensure code isn’t duplicated between scripts, or becomes hard to manage.

A better way to organize and reuse code is with module scripts, a unique type of script that stores a set of functions and variables designed to meet a shared purpose, like managing player money or enemies. Code within module scripts can be used by other scripts. That way, you can call the same function that gives coins from multiple different scripts whenever a player finishes a quest or finds a pickup.

By storing commonly used code in module scripts, it makes maintaining and organizing code easier since changes only need to be made to one module script, rather than updating multiple scripts."

" Summary

Module scripts in Roblox are a method coders use to organize and reuse code. A module script is often stored in ServerStorage (or ReplicatedStorage for client-based interactions). From there, other scripts are able to call functions and variables stored in that module script.

For instance, one game may award points to players for collecting objects. A module script can handle code to give points. Then, scripts for different types of objects can just call the module script function. This reduces the need to reuse code between scripts, making code easier to understand and maintain.
"

People go right to being rude… :rofl: :nauseated_face:
Everyone learns in their own way. Take what everyone says with a grain of salt and see what works best for you. It all comes together in time.

1 Like

You keep saying nonsense.
If you want conversation to continue then dm me.

The opposite, actually. AI is less helpful when you’re learning because it leads you to, as you said, “wrong turns.”

This is a terrible explanation of “balkanization.” And, I’m pretty sure overmodularization is the more common term. Modularization is good, but when you put every little thing into it’s own module, that’s overmodularization.

Who’s “we”? All I see is you being tired of these “excuses.”

If you know modulescripts, then why are you avoiding them? Only beginners who don’t understand modularization avoid modules. In your bio, I see you have “The C Programming Language.” First off, you can just say C, same as you say Luau, secondly I can’t “C” how a C programmer struggles to grasp modules.


Overall, you seem like you don’t truly understand the concepts you’re talking about. Please do some more research before you make claims like that.

1 Like

To add my two cents to OP’s original post before Yarik de-railed it, I recommend learning programming off of Roblox first. Get used to thinking in code, then you can come back and have an easier time.

i don’t like my code split.
I want it all handled in same envirement where i can easily referance needed stuff.
IS this what you wanted to hear?
I like microoptimization and i hate that “balkanization” completelly ruins it.
“Balkanization” is always made for a sake of it lets be real; It doesnt help at all
Well documented code base doesn’t need to be balkanized.
Modulescripts is used by flex devs who never care about perfomance of their product

You sure that i am the one to do that?

I were speaking about opinions fairly untill person above “LMAO FALSE” derailed conversation

Most people like you are stuck at some point, the truth is, experience.
Like everyone else said, start doing small projects.
That would be commisions, small fun games or even a game with your friends! It doesnt matter what type, as long as you have an open mind.
For example, try to look into frameworks. Maybe you want to move to vs code and git hub? Etc.

I think this also. Knowing how to script you just have to laugh at some of things it comes up with.
It don’t take long to realizes how damaging that could be to someone new.

1 Like

Yeah,

When you do know what you’re doing, I find AI to be a nice tool. But I definitely wouldn’t recommend vibe coding to a new programmer (not that I would even recommend it to an experienced one, but you get my point lol)

3 Likes

This is a golden tip. Thanks for that

1 Like

I am strugeling with making a combat system. I am trying to figure it out but its too hard

write down functionalities that your system needs to have; in your case:
(purely focusing on functionality here, no stuff like animations and so on)

  • client tells server to do an attack
  • server receives that call, but we need to validate the action{
  • Is it a tool? Does the client have a tool?
  • Can the tool be used? Are there any attributes/values that block the tool from functioning?
  • Did the action perform too quickly compared to the last one? Can this action even be performed by this specific tool?
  • }

  • The server validates the action, and then the attack is performed{
  • Is there a wait time before the attack actually happens? (animation wind-up, for example)
  • Scan for players in a box or perform a raycast
  • Is the result a player?
  • Should we deal damage to other players (if you don’t want friendly fire and stuff)?
  • Can this player be damaged?
  • Deal damage
  • }

then, once you have your skeleton of the system, you think of the best ways to deal with these things:

for example:

  • Scan for players in a box or perform a raycast
  • Is the result a player?
  • Should we deal damage to other players (if you don’t want friendly fire and stuff)?
local direction = (mouseHitPos - playerOrigin).Unit -- i think i calculated this incorrectly, not sure
local distance = fetchToolAttackDistance
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantInstances = {playerCharacter}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude

local raycast = workspace:Raycast(
   player.Origin, -- this is the position of the HumanoidRootPart, which is accessible through the character
   direction * distance,
   raycastParams
)

if raycast then -- if the raycast hits something
   local hitInstance = raycast.Instance -- get the instance that was hit
   local enemyCharacter = hitInstance.Parent -- this is a 'pseudo' character, assume that this is a character and then validate if it actually is one
   if not enemyCharacter then return end -- the parent of hitInstance is nil, so character is also nil

   local enemyHumanoid = enemyCharacter:FindFirstChildOfClass("Humanoid") -- see if it has a humanoid, characters always have humanoids
   if not enemyHumanoid then return end -- it's not a character, because humanoid is nil

   local enemyPlayer = game.Players:GetPlayerFromCharacter(enemyCharacter)
   if enemyPlayer then return end -- if you don't want to damage other players
   if not enemyPlayer then return end -- if you don't want to damage npc's

   enemyHumanoid:TakeDamage(insertNumberHere) -- take damage
end

scared to ask questions on the devforum? scared of being judged?
AI is your best friend ← PLEASE READ BELOW


AI is useful for stuff like making structures, debugging (not in every case), and overall getting code suggestions that can improve readability and make your code more optimized

AI is bad if you use it purely to CnP the code it gives you
if the AI gives you a method you don’t understand (ex. string:gsub()), copy that line and ask what it does

never copy code without understanding what it does, get the idea of what you’re supposed to do and write it, you can rewrite what the AI did, but only if you truly don’t know what to do

still don’t understand your code? copy it → ask AI → figure out what it does

1 Like

Your problem is you fail to break down a big idea into small steps.
Ask chatgtp to help you with that.

First off, ditch that mindset. If you tell yourself “I can’t improve at scripting,” guess what, you won’t improve at scripting. And instead of “trying” to learn, learn. The way you present your approach to learning to yourself makes a surprisingly large impact.

Secondly, from how I interpreted it, it doesn’t sound like you’re trying to understand these topics on a deep and conceptual level. Ask yourself, “Am I really trying to understand the how and why behind these ideas?” You really have to reason and understand what you’re doing and why you’re doing it rather than inputting some magic sequence of keys waiting for the next step.

It’s all in your mindset.

1 Like

this is very very untrue; yes, you can use modules/modulescripts for sharing values and for storage, but what it’s used for mostly is common/shared routines that are to be executed across other scripts, typcially end results varying on the arguments passed in.

i work at a successful studio and I can tell you for sure we use modulescripts everywhere and anywhere that a piece of code needs to be executed by more than a single script; it’s very rare we have modulescripts that are there solely for storage, and whenever its for that it’s typically just static values like gun stats, etc

to say that modularization is bad for finding issues and does the opposite of organisation is just flat out false; it can add a small amount of complexity depending on your implementation, but it by no means makes organisation inconvenient or incapable; if this is the case for you, the structure of your project is just wrong

“Studio”
Well, it’s not hard to understand that it’s pretty obvious that an indie developer would focus on microoptimization more than a studio. Code patterns will not match either because studio and indie developers both do different things with different scales. While a studio can make a big project, it will never be as optimized as some indie project; hence, no one knows code and optimization as well as a solo dev.
Studio focuses on readability for other scripters, and not all scripters will be on the same level of knowledge. Indie groups/solo devs are almost always on the same level, and if not, then someone with more knowledge would always explain to someone lower what to do; comparing that is beyond stupid.