How do I learn math in lua?

Hey all, math in scripting is unarguably really confusing for beginners. I’ve only been learning how to script for three months and have pretty much intentionally been avoiding math in my scripts. How do I learn, or at the very least, get familiar with it? This includes functions and when to do certain things? Sorry for the wordiness but it’s something that has been really REALLY challenging for me!

Even through watching the, “developer gurus” of Youtube, it really hasn’t helped me all that much. If somebody can get me a resource, a guide, or a simpler way to understand, that would be more than appreciated!

Example script my friend sent me:

local function isStandingOn(position, brick)
    local v3 = brick.CFrame:PointToObjectSpace(position)
    return (math.abs(v3.X) <= brick.Size.X / 2) and (math.abs(v3.Z) <= brick.Size.Z / 2) and (v3.Y >= 0)
end

(That was for his swordfighting game lol, I can send script if anybody is interested!)

Kindly,
@comfled

There is a helpful document by Roblox that explains all the functions in the math library. This will help you understand math.min, math.noise, etc:

1 Like

How often in normal scripts would I use math? If I wasn’t trying to avoid said math? :joy::joy:

It really depends on what you are making. Many developers use functions from the math library to achieve something math related.

I also forgot to mention, this is another great document by Roblox that explains most Mathematical Operators:

That’s really helpful. Just letting you know, I’ve never really been amazing at math in real life. So I’m expecting quite a learning curve, any tips or important things I should know before getting into math?

I’m not the best when it comes to complex mathematics either.

Make sure to test out your mathematical equations, practice to get the hang of it, make sure your equations work correctly, if your equations fail check to see if there are any errors in the output, if all goes wrong you can ask for help on the DevForum.

Hope this helps.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.