Lua questions #3

Im making multiple post asking questions so that any questions don’t get cluttered.

Please also check lua questions 1, 2 ( And this )


How does time() work?

What does typeof do, whats the difference from it and type? When should I use it?

What is .Unit, and how does it work? When should it be used?

What are Lua Libraries?

What’s the difference from CFrames and Position? And why should I use CFrame?

What are some tips on optimizing scripts to make the player receive a better performance?

How would I make a raycast, and how can I change its orientation and direction?

What is Region3? What does it do?

What is Random, and what is a “seed” as described here, how does it work?

How do I get access to CoreGui's, and change their appearances?

How should I take consideration in the way I code to prevent Exploiters abusing flaws into my game / How do I find flaws in my code that are exploitable?

1 Like

How does time() work? Returns Epoch of current system

What does typeof do, whats the difference from it and type ? When should I use it? Typeof is able to get roblox’s instances, for example if you use type(Vector3.new()) it will return “userdata” but if you use typeof(Vector3.new()) it would return Vector

What is .Unit , and how does it work? When should it be used? No Idea

What are Lua Libraries? Lua libraries basically consist of premade functions that you are able to use.

What’s the difference from CFrames and Position? And why should I use CFrame? CFrame is basically a more in-depth Position, Cframe will have lookvectors, rotation, etc while position will as the name says a position value.

What are some tips on optimizing scripts to make the player receive a better performance? Depends the code and what you’re doing

How would I make a raycast, and how can I change its orientation and direction? No idea

What is Region3 ? What does it do? You could think of region as a giant 3D Cube

What is Random , and what is a “seed” as described here, how does it work? If you use random you are able to supply It a custom seed, basically all random functions use an algorithm to get its next values, but if you give it a seed each time, it will be different. for example

Random.new(123):NextInteger(1, 255) 

would be the same ever time

How do I get access to CoreGui 's, and change their appearances? You are unable to access CoreGui itself, but you are able to modify some values using SetCore

How should I take consideration in the way I code to prevent Exploiters abusing flaws into my game / How do I find flaws in my code that are exploitable? Anything on the client side is insecure, have as strong as a server side as you can.

Hopefully the others can answer the ones I missed, and add to what I said

When you want length 1 vectors.

The math behind it won’t really help but it’s just;

local UnitVector = Vector3.new(X / Magnitude, Y / Magnitude, Z / Magnitude)

A piece of code that other people post online for others to use in their on projects.

That’s way too broad of a question to ask like that.

https://devforum.roblox.com/t/what-are-some-micro-optimizations-you-know-of/1896721


I’m not gonna lie here, I feel like you could have gotten good answers to these faster by just googling them.

2 Likes

type() is an inbuilt Lua function which returns the type of a variable. typeof() was specifically made for Luau (Roblox’s own version of Lua) which also works for Roblox datatypes aswell.

local var = CFrame.new()

print(type(var)) -- userdata
print(typeof(var)) -- CFrame