So let’s say I have a runservice.Stepped event in one script, cool. But now it’s too cluttered there, and I also want to do something else every frame, so I move to another script and make a new event instead of putting everything in that one single event. Is this a problem as it could take up more resources?
To explain more, what I mean is. Is it okay to make multiple events that are the same but have different functions because it gets too cluttered in one, or keep it all in one to prevent using up resources?
Yes, you should connect to the same event in different scripts to handle different problems; you should not put everything in one event.
Performance isn’t an issue in this case because it’s not like you’re creating a separate ‘Runservice.Stepped’ event, you’re just connecting to the one Roblox provides on multiple scripts.
Additionally, having a ton of unrelated stuff in a single event makes code hard to read. It’s good to separate concerns
Thank you, it was a question that’s been on my mind for a while.
But even for a runservice event should I also make the same event in a different script if it gets too cluttered there aswell?
I will try my best to not make too many unecessary events though.
But even for a runservice event should I also make the same event in a different script if it gets too cluttered there aswell?
I just want to clarify something. When you do this, you’re not making multiple events; you’re listening for one event across multiple scripts.
But to answer your question, yes, listening to the same event across multiple scripts (or even multiple times within the same script) is better than doing everything in one event.
All the calls to Stepped will queue themselves in order as if they were all in the same script or not.
And listening to the same event across multiple scripts will not be harmful on performance or anything like that right?
And listening to the same event across multiple scripts will not be harmful on performance or anything like that right?
Nah, while listening for events does use some memory, it’s not enough to make a meaningful difference by itself.
When you’ve worked on productions games, you learn to value the simple solution over the “0.1%” more performant solution because in practice that miniscule performance gain isn’t worth the nightmare of writing and maintaining (especially when working with a team of programmers).
I have worked with other programmers before (Ones who literally parented server-scripts to workspace) for a horror game commission and yeah I guess you’re right.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.