How i can create good script?

I would like to learn how to write good scripts, mainly fighting games, I recently created a part of the combat system as in battleground games, but I had difficulties in moments where I had to make a good dash, or the effect of hitting the floor, ie stones, Ragdoll and much more

I watched YouTube guides, used artificial intelligence such as chat GPT, Claude. I’ve read the documentation

If there are people who could provide some useful information, then please provide this information, I would like to learn… I’m still standing in one place, I can’t move forward.

What have you learned in the past 30 days? If you have learned anything, you are moving forward… just maybe slower than you were expecting. Some people learn faster than others, so don’t worry too much about years of experience right now.

Being able to naturally make a good script comes from building problem-solving skills, which you can get by learning to program! Things you’re learning right now will become second nature once you master them, then you can move on to more complicated things. So, if you’re not confident in what you know now, you should master it!

For the last 30 days… I haven’t learned much, so the question is, do people create, for example, the same system of some stones ready-made or by themselves…
The creation formula is still so complicated that looking at the videos I don’t understand, I took more scripts with abilities and watched the contents of the script, I’m surprised and don’t understand what’s going on in these codes ahh, I think I know the base by type While, Variable, Instance and DataStore, I’ve already worked with VFX, creating animations and creating maps… But still I can’t create a good ability, for example, the same ordinary good fireball, not the one that just flies in a straight line and removes health, it’s better with a stand-ragdoll effects, etc

I can think pretty well, although I already doubt it, I can’t think of how to make the same system of stones. In my head, its creation looks like this:
The script takes a Stone from the repository, and creates a clone of it, then spawns at a certain point using Raycast, so that it spawns on the ground, and then some formula for the stone to spawn

Writing code logic is learned while learning to program. You make a few small projects and learn how to make your next project from those.

I also highly agree with @bluebxrrybot 's comment on this. You should learn how to program at your own pace.

Think about what you want to make, exactly how you want it to function then follow this logic you made to structure your program.

Try not to write code without knowing what you are making. As my dad used to say, “Following a path you don’t know where it leads doesn’t always lead you to the right path.”

1 Like

What is “Good Code”? (in my opinion)

Writing good code typically means to write code that is clear and efficient for anyone to read as well as servers to run without lag and performance issues, I can suggest a few topics and tips which vary from easy to hard to implement and understand when writing code like:

[1] OOP (Object Orientated Programming / HARD)

this is a way more advanced topic when it comes to making things like Frameworks (a huge table of functions and events which are very well optimised and wrote that it makes adding new things to the game much easier instead of hard-coding everything… i learnt this lesson the hard way…) To sum this up: OOP is used when creating NEW but SIMILAR objects or data for your game this post helped me to understand what they are and why they’re overpowered when you learn them.

[2] Understanding When To Make A Function (Easy… ish)

one of the things i see people struggle with is making well-named and efficient functions, a-lot of people use Events and just hard-code the functions like so:

Event:Connect(function()
    print("try and avoid this as much as you can")
end)

SOMETIMES, this is necessary in making certain things work but I would recommend breaking down functions into seperate things that you want your code to do, I’ll use a combat system example here:

local function DoubleJump() -- makes the player double jump
	
end

local function Block(enable) -- enables or disables blocking and runs all code involved with it
	
end

local function Sprint(enable) -- enables or disables sprinting and runs all code involved with it
	
end

local function GuardBroken() -- same thing as the Block and Sprint
	
end

local function Dash() -- again, same concept as the others
	
end

this is the best way (in my opinion) to write out functions and it allows for others and even future you to read and understand what things to WAY quicker than reading messy code.

:warning: NOTE

The code above would usually be split into separate Module Scripts which all get required from 1 central “Host” or “Main” script but again, that all comes down to how you want to organise things…

[3] Read Other Peoples Code & Break It Down To Yourself (EASY > HARD)

You said you want to learn how to code fighting games so research on YouTube & Forums the syntax and coding-approach that OTHER people have used to make their own combat systems or Battleground Games, do NOT just blindly watch YouTube tutorials and read code, you have to truly break down every line.

[4] Answering The Stone / Rock Question (HARD)

there are many developers out there who use Pre-Made modules that handle Rock spawning and other more tricky-to-make effects (Customisable Screen Shakers, Rock Debris, Voxel Destruction & Other Destruction Sytems) but if you relate to me in any way… you want to be able to write your own versions of these things which is great BUT… something like a Rock Debris spawner is HARD to make if you don’t understand more advanced math like Pi, Angles and other Geometry, I myself have never looked into making my own Rock spawner but I’ve read others code and they ALL use tricky math to calculate where the Rocks should be placed.

[5] Ragdolls (HARD)

typically, Ragdoll systems are made by creating an invisible part inside of every single body part of every players character and linking all body parts together with a Ball-Socket Constraint instead of a Motor6D when in the Ragdoll state (you can use Attributes for this), again, this is a bit more of a tricky creation but this video helped me out with understanding and even making my own Ragdoll system which I use in my current project.

Hopefully this shines some light on things you may be struggling with! :slight_smile:

1 Like

Thanks for the detailed answer, and to the person from above who also wrote their own options!

I’m going to study oop, I more or less understand how it works since I’ve tried it in another programming language.

Thanks again to everyone :slight_smile:

1 Like