Hey there! How are you doing?
I’m @JuanGamerPlayz_RBLX (but you can call me Juan). I am a game developer on Roblox and I am currently learning the programming language “Lua”. In this post, I will show you how to create a forcefield from the classic era of Roblox!
Table of Contents
What is a ForceField?
Before explaining how to create it step by step, you might be wondering, “What is a 'ForceField?
What on Earth is that?” you might say…
ForceField, in a nutshell, is a protection sphere where it always appears once joining any Roblox experience (i.e. games) or when your character is respawning. ForceField prevents the Humanoid from getting any damage and this class can be changed in terms of how long it will be visible:
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 event called “The Classic,” the old ForceField was faithfully recreated with its original design. This recreation is compatible with any rig, including R6 and R15:
I found it fascinating, but 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 we are going to do is to open the IDE (a.k.a. Integrated Development Environment) software called “Roblox Studio”, where any user can produce their project and be featured on the platform if successful.
You can download the software application by going to the Creator Hub, a website useful to manage and create any development experiences as well as 3D accessories.
After logging on to the website, on the inferior corner, on the left side, select “Studio” and it is going to appear this first pop-up message stating to download it. Press it and after finalizing its automatic download. 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 Roblox Corp.
I will select the first option called “Baseplate”, which includes a spawn point for users 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, we are going to see a bunch of stuff simultaneously; a tab where we can insert free assets created by any Roblox developer called “Creator Store” (on Roblox Studio, we have a synonym that we call as “Toolbox”) 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 us in creating and storing codes and, visually, enhancing the project. For example, if we want to add a geometry, it should be placed under the Workspace service.
Now, 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).
Since we are 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
StarterCharacterScripts and StarterPlayerScripts are not the same!
StarterCharacterScripts handles character-specific behaviors like animations, sounds, and health when the character spawns. StarterPlayerScripts stores scripts that are copied to each player’s PlayerScripts
folder, managing player-specific logic when they join the game.
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 to modify what every player sees on their screen.
After creating a LocalScript, copy the following code below:
--[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 was missing or you believe that you want me to fix it for the better, let me know in the replies!