Random things I've learned

Out of my three years of developing, there is lot’s of things I have learned. I’m going to share a lot with you today.

1: WorldRoot:Raycast() is faster than WorldRoot:GetPartsInPart()

2: If you want to know when a button is pressed and let go, then use GuObject.GuiState

3: Do most of your input on the client, and DON’T USE GuiButton.MouseButton1Click. Use .Activated on a client script instead.

4: If you can use a ModuleScript to encapsulate it, then encapsulate it.

5: Use variables and simplify your code.

6: Disconnect your useless connections to save memory.

7: Try to do all code related with UI on the client.

8: Try to make your UI usable for mobile too. Try using things such as UIAspectRatioConstraint.

9: Do you need some assets? Try Krita (for artwork) and Blender (for 3D models). Most of you probably already know this

10: Want to get a random item from a table? Do

local randomitem = yourtable[math.random(1, #yourtable)]

11: Want to get the up look vector? Here’s how:

local upvector = yourCframe.UpVector

12: TweenService is not like a terribly hard service that will kill your time. DON’T YOU DARE DO IT MANUALLY!! Here’s how to use it:

local TweenService = game:GetService("TweenService")

local part = Instance.new("Part")

local params = TweenInfo.new(3, Enum.EasingStyle.Linear)

local properties = {
    Transparency = 1
}

local newtween = TweenService:Create(part, params, properties)

newtween:Play()

This code will make a part go from fully opaque to fully transparent in three second. Here’s some info on TweenInfo and the ‘newtween’.

13: Use Selection when you’re developing. Open the command bar and then select an object and type in the command bar something like

print(game:GetService("Selection"):Get()[1].CFrame) 

and then look at the output.

List will continue…

Feel free to add anything!! Anything you’ve learned that might be helpful for others?

17 Likes

These are nice and all, but explanations would be nicer.


local upVector = yourCFrame.UpVector
1 Like

Yah, I just realized that. My bad.

1 Like

beginners pet peeves ever,.,.,.,…,.,.

1 Like

about #10… it will tgenerate duplicated values from a table perchance, if you use it multiple times.

so recently i wrote the post that suggests a bit complicated approach.

some guy also suggested another way to go through the table, that one also seem useful.

i’m just sharing in the end, good luck with future experience/projects!

I utilize #6 so much now, i decided to make the connections table for my plugin a global variable (don’t worry, i named it uniquely) so whenever i reload said plugin, it cleans up every connection, it’s kinda become instinct now lol

1 Like

I don’t understand this, aren’t they used for completely different purposes?

2 Likes

I had a recent creation that I could use either, one would’ve been easier, and one would have been faster. Just some random thoughts. Sorry for the misunderstanding.

i think it’s easier and cheaper to cast one ray rather than calculating every colliding part, the advice has logic really

A lot of people make the mistake of using a while loop and then using :GetChildren() or :GetDescendants() in order to update a table. Instead it’s best to use .DescendantAdded and .ChildAdded, this is a issue that a lot of people struggle from.

1 Like