Scripting Damage

The Floor is Lava

Create a Part and name it Lava. Child a Script to the Lava.


Write this code in the Lava’s Script:

This is fine if you have just a few Lava parts. But what if you are making an Obby with 100 Lava parts? The game will slow down if you have that many repeated Scripts running at the same time.

One Script to Rule Them All

Delete all but one Lava part. Move the script down into ServerScriptService. Now that it’s not the child of the Lava, we will need new code.

Select the Lava part and duplicate it over several places so you have many pieces of Lava.

Change your code to look like this. Now every block will deal dame.


This script is a For Loop

for k,n in pairs(game.Workspace:GetChildren()) do

It pulls every listing (k) and it’s value (n) into a list. This script is making a list of all objects in the workspace. It’s like a search function to go through every single object of the Parent Workspace.

Another common loop you may see is a While Loop. Here’s an example-

local timer= 0
while (timer < 10) do
timer = timer + 1

It will “loop” through until counter = 10.