Hey there! How are you doing?
My name is @JuanGamerPlayz_RBLX (but you can call me Juan), a game developer on Roblox, mostly on the artistic side, but going to the coding world, learning the programming language “Lua”. In this post, I will be teaching you how you can create a ForceField from the classic era of Roblox!
Table of Contents
What is a ForceField?
Before we dive into the tutorial, explaining step-by-step, it is important to know the definition of ForceField. You might be wondering, “What in the world is a ForceField?” — Let me tell you:
ForceField, in a nutshell, is an interconnected class on Roblox that appears once joining any Roblox experience. Its visual is a blue translucent aura. Its purpose is to protect the other class, Humanoid (hence, being interconnected), from being attacked for some seconds. If your character dies in-game, the ForceField will appear again:
From 2007 to 2011, during the early years of Roblox, the ForceField feature had a distinct appearance! It was characterized by wireframes that changed colors dynamically every second. Fast forward to 2024, in a significant Roblox platform event called “The Classic,” the old ForceField was faithfully recreated with its original design. This recreation is compatible with any rig type, including R6 and R15:
When I first saw it, I found it fascinating. However, it’s difficult to find a current open-source script for it. Because of this, I’ve decided to create this tutorial to help you make and use it for your projects!
Step 1: Open Roblox Studio
The first thing you will have to do is open the IDE (aka Integrated Development Environment) software called “Roblox Studio”, which allows any user to create their projects and be featured on the platform if successful.
You can download the software application by going to the Creator Hub, a website useful for managing any development asset, as well as 3D accessories.
After logging on to the website, in the inferior corner, on the left side, select “Studio”. As you do so, it is going to appear this first pop-up message stating to download it. Press the “Download Studio” option, and once completed, you will be able to access Roblox Studio:
Step 2: Open a Baseplate
Now that you have access to the Roblox Studio application, you are going to see something similar to my screen below:
If you are seeing it, you are in one of the categories where you can select any sandbox to create your Roblox project, from a simple rectangle, from templates made by the teams from the Roblox company.
I will select the first option called “Baseplate”, which features a part where your character will appear after entering the sandbox called “SpawnPoint”, and a large rectangular floor for walking around. You can choose a different option if you prefer, as the choice is optional and the results will be the same in the end.
Step 3: Open StarterPlayer on the Explorer tab
Now that you have opened your first sandbox, you are going to see a bunch of stuff simultaneously; a tab called “Toolbox” where we can insert free assets created by any Roblox developer inside of an area named as “Creator Store” on the left side and, on the right side, two tabs called “Explorer” and “Properties”:
The Explorer tab allows us to add any feature from the listed services that will assist you in creating and storing codes and, visually, organizing and enhancing the project. For example, if we want to add a geometry, it should be placed under the Workspace service. As for the Properties tab, it is a way to modify the configurations of anything that will impact your project, from changing the colors of the geometry to changing the gravity from the Workspace service, for example.
You will be dealing with the Explorer tab. Leave the Properties tab untouched, and let’s open the service called “StarterPlayer”. To do that, with your cursor, click on the arrow pointing to the name of the service:
In this service, this is where we can modify the configurations of how the Player model behaves once joining your project. Furthermore, it is also possible to see that there are two “sub-services” called “StarterCharacterScripts” and “StarterPlayerScripts”.
StarterCharacterScripts V.S. StarterPlayerScripts
Usually, when you observe these two sub-services, you might think that they have the same functionality. But, I will tell you this, both StarterCharacterScripts and StarterPlayerScripts are different!
StarterCharacterScripts handles character-specific behaviors like animations, sounds, and health when the character spawns. StarterPlayerScripts stores scripts that are copied to each player’s folder called PlayerScripts
, managing player-specific logic when they join the game.
Since we are looking forward to how you can make a ForceField, and this class appears when joining the game, StarterPlayerScripts
is the option!
Step 4: Inserting a LocalScript on StarterPlayerScripts
Hovering your cursor on the name of StarterPlayerScripts, you will see this plus button. This is where we can add instances/classes that are going to be stored and copied to each player’s PlayerScripts
folder:
We are going to click on the button and add a script by the name of “LocalScript”, a class that only runs what the player sees on their screen and can be changed, calling it “Client”. “Script”, on the other hand, only runs on something we call a “Server”, only runs on ServerScriptService, and allows us to modify what every player sees on their screen.
After creating a LocalScript, copy the following code:
--[Services]--
local Players = game:GetService("Players")
--[Creating the SelectBox instance]--
local SelectionBox = Instance.new("SelectionBox")
--[Table of Colors]--
local forceFieldColors = {
Color3.new(1, 0, 0), -- Red
Color3.new(0.5, 0, 1), -- Purple
Color3.new(0, 0, 1), -- Blue
Color3.new(0.5, 0, 1), -- Purple
}
--[Function to Create the ForceField Effect]--
local function createForceField(player)
local character = player.Character
if not character then return end
local bodyParts = {"Head", "Torso", "Left Arm", "Right Arm", "Left Leg", "Right Leg"}
local selectionBoxes = {}
-- Apply SelectionBox to each body part
for _, partName in ipairs(bodyParts) do
local part = character:FindFirstChild(partName)
if part then
local box = SelectionBox:Clone()
box.Adornee = part
box.Parent = part
table.insert(selectionBoxes, box)
end
end
-- Cycle through colors
for cycle = 1, 16 do
for _, color in ipairs(forceFieldColors) do
for _, box in ipairs(selectionBoxes) do
box.Color3 = color
end
task.wait(0.08)
end
end
-- Remove the forcefield effect
for _, box in ipairs(selectionBoxes) do
box:Destroy()
end
end
--[Connect to Player's Character Added Event]--
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
task.wait(1) -- Adjust wait time as needed
createForceField(player)
end)
end)
This LocalScript creates a color-changing ForceField effect around a player’s character when they join the game. It uses Roblox services to manage players, cycles through a set of colors to create the effect, and removes the effect after a set time. The script listens for when players join and applies the ForceField to their character automatically.
Now, if you were to playtest on your project, and your rig is R6, it is going to work as you wanted! If you would like to affect R15, you need to change the name of each body part on the table bodyParts
.
local bodyParts = {
"Head",
"UpperTorso",
"LowerTorso",
"LeftUpperArm",
"LeftLowerArm",
"LeftHand",
"RightUpperArm",
"RightLowerArm",
"RightHand",
"LeftUpperLeg",
"LeftLowerLeg",
"LeftFoot",
"RightUpperLeg",
"RightLowerLeg",
"RightFoot"
}
Hopefully, this tutorial could help anyone out there! If something is missing or you believe that you want me to fix it for the better, let me know in the replies!