I'm working on a script to make footprints in snow. I get an error at all of the l variables in square brackets (Ex: unexpected "[" at line 14), I'm not sure what I'm doing wrong because they usually work for sorting through tables.
There's probably some other problems in there as well so any help with those would be great.
local GlobalFrequency = 10
while true do
local TickA = elapsedTime()
wait(1/GlobalFreqency)
local Surface = game.Workspace.ImprintableMap:GetChildren()
local Char = game.Workspace:GetChildren()
for i=1,#Char do
if not Char[i]:FindFirstChild("Humanoid") then
table.remove(Char, i)
end
end
for i=1,#Surface do
for l=1,#Char do
local DetectDistance[l] = (Surface[i].position - Char[l].HumanoidRootPart.Position).magnitude
end
local DetectDistance = math.min(DetectDistance)
if DetectDistance >= (Surface[i].Size.X + Surface[i].Size.Z)/2 + 5 then
table.remove(Surface[i])
end
end
if DetectDistance ~= nil and math.min(Surface.TriangleCount) <= 4980 then
for i=1,#Char do
for l=1,#Surface do
local x[1] = Char[i].LeftFoot:clone()
x[1]:ClearAllChildren()
x[1].name = CharSub[i + l]
x[1].parent = game.Workspace.ImprintableMap
local x[2] = Char[i].LeftLowerLeg:clone()
x[2]:ClearAllChildren()
x[2].name = CharSub[i + l + 1]
x[2].parent = game.Workspace.ImprintableMap
local x[3] = Char[i].LeftUpperLeg:clone()
x[3]:ClearAllChildren()
x[3].name = CharSub[i + l]
x[3].parent = game.Workspace.ImprintableMap
local x[4] = Char[i].RightFoot:clone()
x[4]:ClearAllChildren()
x[4].name = CharSub[i + l]
x[4].parent = game.Workspace.ImprintableMap
local x[5] = Char[i].RightLowerLeg:clone()
x[5]:ClearAllChildren()
x[5].name = CharSub[i + l + 1]
x[5].parent = game.Workspace.ImprintableMap
local x[6] = Char[i].RightUpperLeg:clone()
x[6]:ClearAllChildren()
x[6].name = CharSub[i + l]
x[6].parent = game.Workspace.ImprintableMap
local Imprint = Surface[l]:SubtractAsync(x)
Imprint.name = SnowPlane
Imprint.parent = game.Workspace.ImprintableMap
end
end
else
print("Unspecified Error")
end
local TickB = elapsedTime()
-- Remove this debugging code --
print(TickB - TickA .. "ms")
break
end
I'm thinking it could be because im using l instead of i for the variable but I don't see any other way I could do it.

3 comments
Ill test this out when I get a chance, thanks
also would I have to change the renaming part? lines 33, 37, 41, 45, 49, 53
Yes