Where should I start to get into mathematical part of scripting

Well, I never say I’m good at math… I’m an average math guy. So I have got trouble understanding complex math scripts and stuffs. Is there any way to understand these math or where should I start as a 13 year old guy.

1 Like

Math is a vast subject - there’s a lot to learn and it all depends on what you need in the given moment. A lot of programming is algebra mostly until you get into 3D maths.

Being 13, you haven’t really had the opportunity in school to take courses that will help you get into it - but that’ll come up in the next few years! Until then, if you really want to learn right now, I’d focus on what you need in the moment. Learn based off of the project that you want to work on.

Don’t look at it and feel overwhelmed and feel like you need to know every type of math to be a good programmer. Believe it or not, a lot of the time programming isn’t actually spent doing more than basic math! Because there are so many different kinds of math - just focus solely on what is important to the project you’re working on, and as the others come up in your school courses take them.

1 Like

Yes but can u tell any resources to start with???

And is it linear algebra u talkin bout?

Like I said - it really depends on what you need to learn. General knowledge is great when it comes to math, but it’s also important to focus on what is really needed so that things stick and you retain information.

The best resource for you would be school as you’re still super young and about to have the opportunity to take specific math courses. However, until then you could try out some Khan Academy courses!

I’m assuming when you talk about complex math scripts it’s 3D math/vectors, so I suppose a good subject to start with would be linear algebra. You don’t really need to dive straight into that, though. Like I said - a lot of programming is spent doing none other than basic math.

Your age doesn’t really matter in this context. What math classes have you taken? Algebra? Geometry? Alg 2? Precalculus? Trigonometry?

The good news is that a lot of the math you need is gonna be given to you by your school. The bad news is that they’re not gonna give you everything.

Just learn as much math as you can, even if most of it won’t be helpful. It never hurts to know something extra. Try self studying a course over the summer or talking with your teachers/parents about taking extra math courses. Strong math skills open many doors for you, so don’t be afraid of learning more.

1 Like

Algebra … And I’m not really good at understanding math

Linear algebra is a very good place to start. Matrix mathematics is at the core of a lot of programming. Once you get the hold of basic linear algebra, Calculus is also pretty important. If you code anything physics related Calculus is essential. Similarly set theory and pure mathematics is the basis of most coding theory. Math is at the heart of everything programming, but you can make it as complicated as you want.

I think you’re looking at it from the wrong lens though. Instead of saying how should I improve my mathematical abilities in relation to programming, you should build on your mathematical abilities using programming. Pick project to work on and the mathematics will follow. For example, how would you go about programming a tennis ball that bounces?

Lets start with an easy one.

I assume you, in 5th grade, learned how to get the circle’s circumference using pi and diameter, very easy right? and later on, you learned that cos and sin is very useful. Trigonometry. So how would I make a circle?

Solution
local fullcircle = math.pi * 2
local numOfParts = 100
local radius = 10
local cos = math.cos
local sin = math.sin
for i = 1,numOfParts do
     local angle = fullcircle / numOfParts * i
     local x = cos(angle) * radius
     local z = sin(angle) * radius
     local part = Instance.new("Part")
     part.Position = Vector3.new(x,0,z)
     part.Anchored = true
     part.Parent = workspace
end

Good luck.

Well, good news for you: Algebra is the foundation of every complex math subject. Getting good at it will definitely save you a lot of trouble later.

If you know anybody in your life who you believe can help you understand, then ask them. Trust me, you can do it.

Math is a unique subject because every concept is usually just a cleverly disguised application of previous concepts. It’s like a bunch of kids standing on each other’s shoulders wearing a coat and pretending to be an adult. If you’re struggling with something, chances are you’re missing one of the concepts that builds up to it.

1 Like

sin/cos is in 9-10th grade aka high-school, those are probably new terms for him,

If you wanna start learning stuff related to math in roblox, you will need to study geometry a little bit.

Not gonna say roblox only uses geometry but that’s a lot of modern coding, if you wanna get started learn what are CFrames, learn math. functions, angles anything, they will all help you.

Understanding CFrames.

However, If I was asked to say, I would say, you don’t need to be a topper at maths to do scripting or programming, I’m 100% sure none of us in the world know 100% of the maths, and you know? as @Thernus said maths is really a vast subject, you need imagination and some basic maths for scripting

I myself not a topper, but it does not stop anyone from being a scripting/top-scripter, I know we need maths for some stuff at scripting like math.sin in Lua, but thats not everything,
85% of what scripting do does not include complicated maths, however for real-time physics stuff, you need a bit of maths, but not highly complicated too, in my country you learn these sin,cos,tan etc at grade 10, and you learn all these are 16 max, idk about other countries, but trust me, nothing is impossible, you just need some experience and some self-confidence

There is also some quote says “Imagination is powerful than knowledge”, knowledge is limited to all of us in the world, and yes imagination is what which keeps the knowledge at action and find and discover new things, try to learn simple scripting, then gradually go hard, especially I would suggest you to self-learn why? players who are not good at maths, have difficulty in finding logical questions and stuff like scripting, if you watch some random youtuber tutorial in yt, you would find scripting very hard, but I self learned, and now I always suggest anyone who ask me to self-learn, when you self-learn, you would find your own methods for dealing with things, and you would have some stuff in mind

Good luck

oh , thought it would be easy. I guess i was wrong, but the rest of replies are useful.

1 Like

so first start by asking your self what do i want to do

so lets say you want to make a part move in a circle but you don’t know how

first step search google or this forum or anywhere that has a result for what you want

then you might come across a post like this

now this is where most people go wrong
don’t just copy and past the code into your project and call it a day

you need to go over each line of code line by line until you understand what each line of the code is doing and how the code as a hole is working

so in the link above you find this code

local radius = 50
local Xc = 0
local Yc = 0

for angle = 0, 359 do
  local x = radius * math.cos(math.rad(angle)) + Xc
  local y = radius * math.sin(math.rad(angle)) + Yc
  part.CFrame = CFrame.new(x, y, 0)
  wait()
end

once you go over each line you might end up with thinking something like this

local radius = 50 -- ok this looks like they are saving the radius of the circle in a variable called radius
local Xc = 0 -- umm what the hell is Xc???
local Yc = 0 -- and i have no idea what Yc is

-- looks like they are looping from 0 to 359
for angle = 0, 359 do
  -- radius * cos??? math.rad??? + Xc
  local x = radius * math.cos(math.rad(angle)) + Xc
  local y = radius * math.sin(math.rad(angle)) + Yc
  -- set the part to a new cframe with the x and y value
  part.CFrame = CFrame.new(x, y, 0)
  wait()
end

so now you could play around with the code and see what happens

so you might change Xc = 0 to Xc = 10 and then run the game to see what happened then after changing it a few times you might notice that it effects the position of the circle

so now we kinda know what Xc and Yc is doing but we don’t know how its doing it

so maybe now you might move onto trying to understand what math.cos is

so we start searching google math.cos to see what it is and you might find this

and then you might search google for cosine to try and understand what cosine is

you might write a small amount of code like this to see what it prints

for i = 0, 359 do
    print(math.cos(i))
end

then you might do something like this

for i = 0, 2000 do
    local x = math.cos(i)
    part.CFrame = CFrame.new(x, 0, 0)
    wait()
end

then you might work out that cosine is like a wave that keeps making the part go left and right left and right

and you keep dissecting and messing around with the code until you feel you have a good understanding on whats happening

you might also want to search around for different methods of making part move in a circle and you might find different ways to do that same thing then you will want to try and understand how them different methods work

then finally once you find a method that you like and you understand it then write the code in your own style of coding

so you might end up with code looking like this

local runService = game:GetService("RunService")
local position = Vector3.new(0, 4, 12)
local radius = 50
local speed = 0.5
local counter = 0

runService.Heartbeat:Connect(function(deltaTime)
    counter += speed * deltaTime
    local x = math.sin(counter) * radius
    local z = math.cos(counter) * radius
    local offset = vector3.new(x, 0, z)
    part.Position = position + offset
end)

then move onto the next thing your trying to do

but everyone learns differently so while this is how i learned maths by dissecting and rewriting code it my not work for you

the main thing is just try to have fun while you learn and experiment

3 Likes

+, -, ×, /, %, +=, -=, *=, %=, =, ==, ~=, Roblox’s math library, Vector3, CFrame and math.noise()

Edit: ^, ^= and math.pi()

Aside from, obviously, Algebra, it is mostly Trigonometry and Geometry that have been helping me the most, so, I will mainly focus on those.

You are young. Although you havent learned something like Trigonometry in school, you can still learn it as, in my eyes, it is a relatively simple concept to grasp with the correct explanation. Perhaps it will even give you an edge in school when you get there!

Ideally, if you feel forced to learn it, either try to ask somebody who has had the subject or try to Google stuff. What Trigonometry is more useful for is mostly, from my experience, grabbing angles between vectors, calculating distances, rotating things based off angles, etc.

As for Geometry, I dont really feel like it is as useful but, for the most part, it revolves around knowing to work with vectors, for the most part.

I am unaware as to what sorts of stuff you are trying to create. Note that I have only been scripting for a little more than an year so do not take my word for granted. Programming has so many possibilities that you will never know what you will need, especially in math / physics.

Although I am no teacher, if you wish, you can try getting in contact with me and I can try to explain you the basics of trigonometry. I would try to write them now but unfortunetly I am writing on my mobile so, that sucks.

No matter your decision, I applaud you for having the capability of scripting and having much interest in the area with your age, and you will see that once you learn more and more, new, huge horizons will show in front of you.

u forgot ^ and ^=

edit : and pi

1 Like

My spacial reasoning is very low. I actually realised it in a math test I took las week.