#Is this a match system script good (in terms of optimization and everything else)
1 messages · Page 1 of 1 (latest)
no, but the real question is: does it work?
yes
it works but i feel like theres a better way to do it
i just dont know how
also it feels inefficient because if i need to add more stuff
it gets messier to code
that's normal. you'll do it better the next time. the fact that its working is what matters.
rinse and repeat and you'll be pro eventually 🙂
would you say theres anything specificly that i could stop relying on
not really. could reduce your nesting but that's not a big deal at your level
just keep making stuff.
you can't make good code without first making a lot of bad code.
I'm a Never Nester and you should too.
Access to code examples, discord, song names and more at https://www.patreon.com/codeaesthetic
Correction: At 2:20 the inversion should be "less than or equal", not "less than"
ohh thats what nesting is
** You are now Level 4! **
alr lemme watch the video
ooo alr
that makes sense
isnt more lines bad tho for optimisation
you shouldn't be bothering really at all with optimization at your level
but no, more lines does not reduce performance.
there is a cost associated with calling functions but bruh that cost is so insignificant
don't prematurely optimize when you barely know how to write in the first place
oh
sorry im just trying to build good habits for later on
yes, not focusing on optimization is actually a very good habit for you to learn for later on
i know there's a wide obsession with optimization, but it really does more harm than good
it will stop you making stuff because you're too busy wondering whether or not what you have made, or want to make, will be made perfect and flawless, when in reality the micro optimizations you're trying to implement will have literally zero impact on your game at all because your frame time is already far below the limit
if, each tick, your frame time goes above 1/60'th of a second in order to maintain stable 60fps, even for a single frame (lag frames), then maybe start looking at optimizations. but doing so before is just a huge waste of time and effort.
and more often than not, your lag will come from one or two places that are very expensive, like doing 1000 raycasts and spatial querying in a single frame for some projectile or something. that's where your efforts should be focused. not on whether or not the order of your if statements are correct, or if extra lines are less performant.
another example of something very expensive that should be optimized is checking the distance and line of sight between each player to every other player, that's an expensive algo
this will never even be close to that in terms of cost.
so don't sweat the nanoseconds 👍
oh alr
only reason rn is im working towards making a proper game
cuz of that im kinda worried abt the client memory usage. IDK if its important but im friends with some of the developers of tennis zero and they seemed to care abt the memory usage going higher then 1.9k
i dont even know how to check that 
ohhh ok so mainly projectiles or just a lot of one thing
i thought lines had a big influence
heartbeat/renderstepped give you a deltatime, which is how long has elapsed since the previous frame
if that deltatime is > 1/60 then you have lagframe. there's other ways to check it, but essentially you just want a stable 60fps. if you get less than that, there's a bunch of tools to figure out where your frametime is going like the microprofiler, but you shouldn't really worry about that until much later
but yea no it's not the line count that matters, it's the work being done that matters.
would an example of this be games with big maps that has a map system
local a=1+1 and local a=workspace:Raycast(etc) are both one line, and one is substantially more expensive than the other because it does more work
has nothing to do with the map. it has everything to do with the amount of work the computer has to do. it's an O(n*n) formula, roughly, meaning the sheer number of calculations increases exponentially as more players join
i think the actual number is factorial because you get some overlaps, you only need to check player A to player Z once, because player Z to player A is the same result
ohhh alr
AI Overview
The formula for the number of unique pairs of distinct numbers from a set of 'n' numbers, where the order of the numbers within the pair does not matter (e.g., {A, B} is the same as {B, A}), is given by the combination formula "n choose 2".
This formula is:
Coden * (n - 1) / 2
point is, performance is regarded by work. not by lines.
so yeah, i'd say stop relying on wondering whether or not what you have is perfect and optimized and everything else, and just simply keep making stuff. the more stuff you make, the better you'll get. roblox is extremely forgiving.
yep understood
how long have you been coding for
too long
what games have u made
outta curiosity
actually idk why i asked that
i just see a lot of experienced coders but from the looks of it they don't seem to be working on any games or anything
which kinda makes me wonder why
i actively work on games, thinking of making combat game
i just dont feel a need to go into it
why
the thoughts of making a successful game or a game for the money doesnt hit you?