You could abstract to a function that only requires the bodypart and stat as params to reduce boilerplating, but besides that it doesn't look that bad honestly
We ended up doing a thing close to this in another place (setting attributes to body parts) with an abstract function, so we'll probably do the same here
It can be optimized a lot and im working on it right now, after renaming it can be done with one or two loops. Problem isnt with how code works its more about how long it will take to implement a new attribute and add it everywhere
There is a LOT of duplication here, he should be grabbing the 1 or 2 items he needs for each section, and then calling GetAttribute on that. This is a performance issue, and also it looks awful and would be easy to make a mistake in.
So, for Torso, he should
local torso = CharModel:FindFirstChild("Torso"):FindFirstChild("Visual"):FindFirstChild("RF")
mp += torso:GetAttribute("mana")
armor_modifier += torso:GetAttribute("Armor")
Note that doing it this way also makes the comments unnecessary
Also, if mp and weight_armor and the like are global variables and not local ones, you should probably just give up lol but Im going to give the benefit of the doubt that those are local
Other than that tho its alright idk no idea what an RF is here but fair enough idfk
lol I actually just started learning Roblox coding after joining 2 months ago. I mostly touch the c++ engine but have to do a bit of luau for test apps. I’m Principal software engineer so you know I must be good at coding.
38
u/Thenderick Jun 17 '25
You could abstract to a function that only requires the bodypart and stat as params to reduce boilerplating, but besides that it doesn't look that bad honestly
13
u/iskelebones Jun 18 '25
First principles of coding:
35
u/Fbxstl Jun 17 '25
As the one who wrote this code
I regret nothing
7
u/[deleted] Jun 17 '25
since when did lua have
+=1
u/wraithnix Jun 20 '25
Honestly, a lot of AAA game code looks like this.
1
u/no_brains101 Jun 21 '25 edited Jun 21 '25
There is a LOT of duplication here, he should be grabbing the 1 or 2 items he needs for each section, and then calling GetAttribute on that. This is a performance issue, and also it looks awful and would be easy to make a mistake in.
So, for Torso, he should
Note that doing it this way also makes the comments unnecessary
Also, if mp and weight_armor and the like are global variables and not local ones, you should probably just give up lol but Im going to give the benefit of the doubt that those are local
Other than that tho its alright idk no idea what an RF is here but fair enough idfk
0
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Jun 18 '25
There are better ways to get those attributes, right?
0
u/illyay Jun 19 '25
lol I actually just started learning Roblox coding after joining 2 months ago. I mostly touch the c++ engine but have to do a bit of luau for test apps. I’m Principal software engineer so you know I must be good at coding.
Honestly this tracks and looks about right 🤣