Any Tips on Managing Your Game?

I have been I roblox scripter for over a year now and am still working on my second game. I never seen how games really manage there scripts, for some reason or another people keep this a secret. I feel like a lot I do is inefficient and outdated so is there any tips on how to manage and organize your game so it is more efficient?

The game is a RPG Maze Game.

I store my scripts in two files in ServerScriptStorage. One for Modules and the other for just Game Scripts. In the first one I have 2 the second 10:

My code does NOT have comments but I am gonna add some soon.

My StarterGui looks like this:

It has a folder where I keep sound effects, a fonder where I keep music and a folder where I keep a older version of my player’s leaderstats to see when they change.I have 2 scripts just, there, because they don’t need a Gui or Frame to be in, and then 5 separate ScreenGuis. I am not sure whether to use 1 or 10, but I just used 5.

My workspace is more managed then my first game:

It has 16 separate folder of Workspace-stuff from Maze-walls, to Dialog-Parts. I use to just through everything in there but I think is is a little better.

Lastly my ReplicatedStorage looks like this:

It is made up of 12 folders holding varying things from Inventory Data, to Fruit-Storage. Until recently when a friend told me I should use it, I had no Idea what ReplicatedStorage was for, let alone how to use it. Now I see it is useful but I still wonder if there is other Tips, Tricks, Tactics, or just whole features that I am missing out on. I supposed there is no RIGHT WAY to manage your game but I am sure there is some ways I can improve without learning the hard way.

2 Likes

I personally think if your method works and you know where to find what your method is absolutely fine. (Not really answering your question, sorry)

1 Like

In terms of organization, I try to condense all of my stuff into as little as possible and add comments. I try to keep a maximum of 5 server scripts in a game (by server scripts I mean big scripts that handle a lot, not a single server script inside a part), while having as little localscripts as possible. I also try to limit the amount of modules based on what I’m doing. When it comes to UIs, I tend to spread my UIs out into multiple ScreenGuis to make it convenient for me to move stuff around. I try to not have variable objects, but rather [Remote/Bindable]Events and [Remote/Bindable]Functions inside a folder in ReplicatedStorage that pass data to other scripts although I do sometimes use value objects just because I’m lazy.

4 Likes

I’m a very organized person, so I often layout my projects by making sure that everything is properly indexed, which includes the assets and the scripts. I also try to keep the number of scripts as low as possible because you honestly don’t need to have a script for every single thing. Due to that, I often form core/main scripts on both the server and the client, which further helps with organization. I also layout my scripts almost exactly the same, whenever possible. However, you definitely do not need to go as far as I go because I do have OCD, so I’ll just constantly organize my entire game. However, I do hope that I helped in you in some with organizing your game.

2 Likes

Okay so firstly, in response to what the others have said, it SEEMS like they’re saying have very few module scripts, don’t dooooo thisssssssss. Have lots of module scripts, all sharing a same table (maybe two tables, one for non function things, the other for functions).

I structure my explorer like this

So what happens is basically, I have a module for each frame, than I have a script referred to as UIElements. In UIE, it requires everything under UIModules, and passes to them a reference to MainUI, the screen gui object so they don’t have to reference it each time, Status, so they can tell what is happening in all the other frames, and then a UIE table, which contains a load of functions like :HandleButtonEffects.

This bit of code was very briefly written as a first draft, but it does communicate how this system works rather nicely.

We can see UIE storing a custom event I made (MainFrameOpenChanged), which is created in one script in UIModules but then accessible to all. And we can also see the reference to MainUI being used being I don’t have to do the whole game.Players.LocalPlayer.PlayerGui.MainUI crap each time lol.

I might write a tutorial on this, I’m interested in it, and historically have been TERRIBLE at it. When you start to manage a seriously large project (this one is about 40k lines), you need to go ultra modular. Scripts averaging around 200 lines

5 Likes

for client stuff i use modules, and to protect them against stealing i store every module in a table and destroy them. so the exploiter cant steal them nor can they read them. its a pain full process to do but in the end its worth the security.

An exploiter definitely can read the source code of your client module scripts even if you delete them.

3 Likes

Just curious, what’s your twitter module do?

@DeepBlueNoSpace pretty much covered what was on my mind.

ModuleScripts are sooooo useful, I 100% suggest you look into modularisation and having one module carry out only one specific task. Overall, it makes your game way more organised, professional and easier to read/continue to develop and update.

I’m going to be making a video tutorial on modularisation in Roblox sometime in the near future, so if you’re interested keep a look-out for that.

3 Likes

Handle the twitter frame. Some of the naming isn’t 100% consistent, that should be changed and thanks for bringing it to my attention

1 Like

100% true but it does make it harder. You’re likely to stop a lot of petty script kiddies this way (until one of them figures it out and creates a tutorial on what to do)

I can’t find how to use them. I don’t even use local functions often in my scripts until recently(Why Module Scripts? - #13 by DataBrain), I never even used them. Give me 3 or 4 in depth example.

I don’t really think you need 3 or 4 examples. (I also hate to be picky, but pleases are nice too! You sound abrupt overwise)

These are the same things

local Table = {}
--script
local Table = require(Module)
--Module
return {}

A module script basically just returns a table
An actual use case might be

--Module
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer

local Table = {}
function Table:GetHRP()
   if not LocalPlayer.Character then return nil end
      return LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
   end
end

return Table

--Script
local PlayerFunctions = require(Module)
local HRP = PlayerFunctions:GetHRP()

It makes your code a lot tidier. Obviously this is a silly example, but hopefully it should set off your imagination. I also showed some examples with how I used them earlier to give them even more functionality.

I get it it’s a place to call functions. It is suppose to make It easier. But I most likely won’t call that function more then twice so is it not a waste of space. Even if I were to call it more then twice, I could make that function in my code could’t I?

Maybe it is because my scripts are wrongly layout. Is this where a Module may come useful and if so how?

Here is my MusicCode in my game. It has took so so many tries to come up with this(How do you check if the player is in certain area - #20 by Suitable_Jay). It is located in StarterGui(or PlayerGui) and is used to play certain music when a player has entered one of a handful of ranges:

-- By Mangson Team! --My Tag I am not sure if you should do this

while wait() do -- This basiclly waits for a value named "IsLoaded" I placed in Backpack to become true.
	if game.Players.LocalPlayer:WaitForChild('Backpack').StatsFolder.IsLoaded.Value == true then
		break
	end
end

local plr = game.Players.LocalPlayer
local CurrentField = 'None' --The Current Field(or Range) the player in is
local head = plr.Character.Head 
local Music = script.Parent.MusicFolder --- The folder that contains all the Music for the certain field(rang)

local function loadmusic(music)--A function that slowly winds a Sound on so it's not so sudden 
	music.Volume = 0
	music:Play()
	for i = 0,music.Volume,0.05 do
		wait(0.05)
		music.Volume = i
	end
end

local function unloadmusic(music)--This does the opposite of the function above
	for i = music.Volume,0,0.05 do
		wait(0.05)
		music.Volume = i
	end
	music:Stop()
	music.Volume = 2
end

while wait(0.1) do -- The main part of code is next. This loop is needle to continue checking if the Fields have you in
	for i,part in ipairs(workspace.FieldPartFolder:GetChildren()) do--Goes through a folder full of FieldParts. Which are just parts that consist of a description for another script, and 4 attachments 
		if part.a.WorldCFrame:toObjectSpace(head.CFrame).Z > 0 and part.b.WorldCFrame:toObjectSpace(head.CFrame).Z > 0 and part.c.WorldCFrame:toObjectSpace(head.CFrame).Z > 0 and part.d.WorldCFrame:toObjectSpace(head.CFrame).Z > 0 then --If player's head is inside the range on all axis
			if CurrentField ~= part.Name then -- If the player is not already in the Field
				for i,v in ipairs(Music:GetChildren())do -- Goes through all music 
					if v.Playing then -- Checks if playing
						unloadmusic(v) -- Turns them off
					end
				end
				CurrentField = part.Name -- Setting CurrentField 
				loadmusic(Music[part.Name]) -- Turns on the Current Field's music
			end
		else
			if CurrentField == part.Name then -- If the play is outside and CurrentField says otherwise 
				CurrentField = 'None' --Makes it none
			end
		end	
	end
end


Also Thanks for helping me, your kindly parting time, effort, and patients into helping those like me for no gain.

There are multiple ways you could use a module script(s) here. For example, a MusicObject module could be useful if you wanted to give different tracks different volumes. You could easily have a loud track and a quiet track tweened off and on using modules and OOP.

Another reason to implement modules would be to give you more control over your music being played. Imagine your game had a cutscene that you didn’t want interrupted by background music. Right now there’s no way to pause all the tracks being played or to play only one sound. With a module script you could easily pause the music being played.

Off topic: Does your loadmusic() function work? It seems to me like it doesn’t because you set the music.Volume to 0, and then in the for loop you increase the volume to the music.Volume (which is 0, so the volume doesn’t change). You can fix this by saving the original volume (presumably the max) with a variable such as: local volume = music.Volume and then change your for loop from music.Volume to volume.

The way, I manage my scripts, I don’t know if its the greatest way but it helps me. I keep all my client stuff in one big local script, I use the do end scoping format to still keep things tidy and concise. I as well do the same for the server. I also have a module script that I use for quick functions and variables that I find myself using often. This way has helped me, you should try it. It helps different aspects of your game stay separate yet together. I hope i helped.

Ya so you’re correct, you don’t actually need a module script, everything is technically possible with 1 local and 1 regular script.

However, module scripts break up your code into more manageable chunks, and force you to (almost accidentally) form good habits. I would recommend just trying it the way I’ve set it up (and if you need more help setting it up the way I have, ask!), and letting us know how it goes.

2 Likes

I don’t know , I have no speakers. It’s a old script.

I just looked into it and each music has a Volume Int Value Object in it to see the Default Value. I forgot to add .Value to the end of it, and change it’s name.