Studio Tips and Tricks I've Learned

Hi there! There may obviously be a few of these that you already knew, if not all. I’m not claiming to be a pro at all by posting this. I’m just wanting those out there that are struggling with a few annoying aspects of developing in Roblox Studio to be able to bypass those struggles like I wasn’t able to at first. So, without further ado, here are a few tips and tricks that I’ve learned in Roblox Studio.

1) This is a rather new one for me. But I noticed in some advanced scripters’ YouTube videos that they were commenting out entire sections of code with what seemed to be the click of a button. I found out that you can actually do this by highlighting a section of code, then pressing CTRL + “/”.

2) Another great one is UIAspectRatioConstraints. I didn’t find about about these until this month (9 months into my coding journey). They keep your gui objects in a specific ratio. So they come in handy when used in plugins like AutoScale Lite. But they can also be used to just keep your images square if you insert one into that image. UICorners are also a thing, so you don’t have to use the old plugins for adding rounded corners.

3) If you don’t know what “return” is in lua, or coding in general, LEARN IT! That was probably one of the biggest things holding me back as a scripter in the beginning. It will help you out tons if you understand that from the get-go.

4) When hovering over a model you can hold down ALT to select parts inside of it. It’s a good idea though to just avoid this when unnecessary (by using folders instead of models).

5) Get the Reclass plugin. It’s very useful for changing lots of objects to different objects while maintaining their children and properties.

6) Holding down CTRL while scaling items will scale that axis of the object equally on both sides instead of one. Also, hotkeys for moving, building and resizing are much faster than clicking between them; CTRL + 1, CTRL + 2, CTRL + 3.

7) If you’re experienced at all then you also know that when it comes to coding, the answer is almost never what you expect. The best thing I’ve found to fix bugs after hours of looking it over and re-printing / re-writing code to get a different point of view on the problem. A good way to do this is by asking someone in the Unofficial Roblox server in their #development-help channel. If all else fails, I’ll post a detailed explanation of my problem on the Dev Forum. Doing those three things will almost always solve your problems. If not, sleep on it and hopefully it will come to you.

8) You can store multiple local variables on the same line by using commas such as in this example:

local var_1, var_2 = "blue", "purple"

You can also write things on the same line after defining a variable (and in general):

local var_1 = "blue"; var_1 = "purple"

9) Instead of using spawn() (because of reasons) use:

task.spawn(function()

-- code here

end)

This will wrap a function in a coroutine and call it at the same time because of the “()” at the end. It does the exact same thing that spawn() tries to do, just without the negative side effects.

10) When you want to replace lots of words / phrases that are the same with one new word or phrase, hit the command CTRL + F while in a script. It’s called find and replace. Very nice if you haven’t been using it yet.

11) You can make conditions into bool values (or anything into bool values) by putting a “()” around it. This is especially useful for gui cases like this:

local pages
local tabs

for _, tab in pairs(tabs:GetChildren()) do
  -- given that each tab and designated page name are the same..

  tab.MouseButton1Down:Connect(function()
    for _, page in pairs(pages:GetChildren()) do

      -- you can do this
      page.Visible = (page.Name == tab.Name)

      -- instead of
      if page.Name == tab.Name then
        page.Visible = true
      else
        page.Visible = false
      end

    end
  end
end

12) And lastly viruses. Oh boy I’ve had my fair share. If your game is literally freezing at the start and you have no idea what’s causing it, there’s probably a backdoor somewhere. A good way to find and remove this is by using the binoculars,image
and using the drop down arrow to select “Script Only” and look for suspicious key words like getfenv or require (if they’re not yours). Another way to see right away if a free model script is suspicious is if you find something like this (found in the common boombox):

And yea that’s most of the stuff I can think of right now. Please let me know what you thought by replying to this topic, thanks!

22 Likes

wrong link i suggest pasting the server invite link also there are a lot of unnofficial roblox devolopment servers maybe add the fact that the link is of discord since for ppl who dont know about it it just shows a login page and once u make an account a no text channels msg

You can write everything on the same line, as Lua ignores whitespace during parsing.

local function f(x)return x+1 end print(f(1))print(f(2))

In what way is the first example more efficient? If there is any difference it should be less efficient since it will do an unnecessary test on the result of the and expression.

3 Likes

I’d imagine these tips would be useful to people who don’t know them, but I’d like to offer some constructive criticism. Particularly on tips 8 and 9.


local var_1, var_2 = "blue", "purple"

is not the same as

local var_1 = "blue"; var_2 = "purple"

In the first code snippet, both variables are local. In the second code snippet, only var_1 is local.
If you want to do something equivalent, you’d do this:

local var_1 = "blue"; local var_2 = "purple"

My second critique expands upon what Halalaluyafail3 was saying about abusing and.
While this works, it makes the code less readable. Not only that, it appears to be slightly less performant.

I did a naïve test because I was curious and using simple if statements seems to be ~60% faster.

function findTimeTaken(fun,loopAmount)
	local beginTime = os.clock()
	local testInput = true
	for i=1,loopAmount do
		fun(testInput)
		testInput = not testInput
	end
	print("Time taken: ",string.format("%f",os.clock()-beginTime))
end

local speed

local function functionA(on)
	speed = on and 16 or 0
end

-- instead of

local speed

local function functionB(on)
	if on then
		speed = 16
	else
		speed = 0
	end
end

findTimeTaken(functionA,10000000)
findTimeTaken(functionB,10000000)

Performance isn’t the issue here, since it’s basically negligible for most things. It just adds unnecessary complexity.

I wasn’t saying they’re the same. Oh, I didn’t know that about the performance. I’ll be sure to update

1 Like

Alright, I’ll be sure to fix that. Thanks for letting me know

1 Like

For the white space part, yes I knew that but it looks more readable. But had no idea the condition part wasn’t more efficient. I just assumed less words = more efficient. I was clearly wrong lol

You don’t have to put parenthesis around a comparison operator, they are operators and can be used in any context where an operator can be used.

Example:

local x = 1
local y = 2
local z = x == y

So this

page.Visible = (page.Name == tab.Name)

doesn’t need the parenthesis and can be written without them.

page.Visible = page.Name == tab.Name
1 Like

Once again, I took readability into account; but thank you for the heads up.