#Is this a match system script good (in terms of optimization and everything else)

1 messages · Page 1 of 1 (latest)

ashen cloak
chrome hollow
#

no, but the real question is: does it work?

ashen cloak
#

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

chrome hollow
# ashen cloak yes

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 🙂

ashen cloak
chrome hollow
#

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.

ashen cloak
#

yeaa ive only been coding for a week or smth

#

so im pretty bad

chrome hollow
ashen cloak
#

ohh thats what nesting is

dusty flowerBOT
#

studio** You are now Level 4! **studio

ashen cloak
#

alr lemme watch the video

ashen cloak
#

isnt more lines bad tho for optimisation

chrome hollow
#

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

ashen cloak
chrome hollow
#

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

chrome hollow
# ashen cloak

this will never even be close to that in terms of cost.

#

so don't sweat the nanoseconds 👍

ashen cloak
ashen cloak
ashen cloak
chrome hollow
#

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

chrome hollow
ashen cloak
chrome hollow
#

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

chrome hollow
#

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

chrome hollow
#

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:
Code

n * (n - 1) / 2

#

point is, performance is regarded by work. not by lines.

chrome hollow
ashen cloak
chrome hollow
#

too long

ashen cloak
#

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

chrome hollow
#

i actively work on games, thinking of making combat game

#

i just dont feel a need to go into it

ashen cloak
chrome hollow
#

i meant explaining it to you i dont see much a reason

#

i'm doing other things too y'know

ashen cloak
#

ah alr mb for prying into your business

#

im just curious on what experienced coders do

#

cuz i wanna try become good at coding

#

anyways ty for the info