Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How could I make this more efficient?

Asked by 9 years ago

This is extremely unefficient. Any suggestions/changes?

local dv = workspace.DistanceValues -- folders
local pt = workspace.PlayerTimes -- folders
local pn = workspace.PlayerNames -- folders
wait(15)

local players = {}
for _, player in pairs(game.Players:GetChildren()) do
players[player.Name] = player
print(players) **-- It also outputs nil**
end










local n = Instance.new
local l = game.Lighting
P8D = l.P8D
P7D = l.P7D
P6D = l.P6D
P5D = l.P5D
P4D = l.P4D
P3D = l.P3D
P2D = l.P2D
P1D = l.P1D
P8T = l.P8T
P7T = l.P7T
P6T = l.P6T
P5T = l.P5T
P4T = l.P4T
P3T = l.P3T
P2T = l.P2T
P1T = l.P1T
Name1 = l.Name1
Name2 = l.Name2
Name3 = l.Name3
Name4 = l.Name4
Name5 = l.Name5
Name6 = l.Name6
Name7 = l.Name7
Name8 = l.Name8


w = workspace
wait(4)
local childs = game.Players:GetChildren()
for x = 1, #childs do
    print(childs[x].Name.." nammmmess!!!!!!!!!!!")
    if x == 8 then
    P8D.Parent = dv
    P7D.Parent = dv
    P6D.Parent = dv
    P5D.Parent = dv
    P4D.Parent = dv
    P3D.Parent = dv
    P2D.Parent = dv
    P1D.Parent = dv
    P8T.Parent = pt
    P7T.Parent = pt
    P6T.Parent = pt
    P5T.Parent = pt
    P4T.Parent = pt
    P3T.Parent = pt
    P2T.Parent = pt
    P1T.Parent = pt
    Name1.Parent = pn
    Name2.Parent = pn
    Name3.Parent = pn
    Name4.Parent = pn
    Name5.Parent = pn
    Name6.Parent = pn
    Name7.Parent = pn
    Name8.Parent = pn
elseif x == 7 then
    P7D.Parent = dv
    P6D.Parent = dv
    P5D.Parent = dv
    P4D.Parent = dv
    P3D.Parent = dv
    P2D.Parent = dv
    P1D.Parent = dv
    P7T.Parent = pt
    P6T.Parent = pt
    P5T.Parent = pt
    P4T.Parent = pt
    P3T.Parent = pt
    P2T.Parent = pt
    P1T.Parent = pt
    Name1.Parent = pn
    Name2.Parent = pn
    Name3.Parent = pn
    Name4.Parent = pn
    Name5.Parent = pn
    Name6.Parent = pn
    Name7.Parent = pn
elseif x == 6 then
    P6D.Parent = dv
    P5D.Parent = dv
    P4D.Parent = dv
    P3D.Parent = dv
    P2D.Parent = dv
    P1D.Parent = dv
    P6T.Parent = pt
    P5T.Parent = pt
    P4T.Parent = pt
    P3T.Parent = pt
    P2T.Parent = pt
    P1T.Parent = pt
    Name1.Parent = pn
    Name2.Parent = pn
    Name3.Parent = pn
    Name4.Parent = pn
    Name5.Parent = pn
    Name6.Parent = pn
elseif x == 5 then
    P5D.Parent = dv
    P4D.Parent = dv
    P3D.Parent = dv
    P2D.Parent = dv
    P1D.Parent = dv
    P5T.Parent = pt
    P4T.Parent = pt
    P3T.Parent = pt
    P2T.Parent = pt
    P1T.Parent = pt
    Name1.Parent = pn
    Name2.Parent = pn
    Name3.Parent = pn
    Name4.Parent = pn
    Name5.Parent = pn
elseif x == 4 then
    P4D.Parent = dv
    P3D.Parent = dv
    P2D.Parent = dv
    P1D.Parent = dv
    P4T.Parent = pt
    P3T.Parent = pt
    P2T.Parent = pt
    P1T.Parent = pt
    Name1.Parent = pn
    Name2.Parent = pn
    Name3.Parent = pn
    Name4.Parent = pn
elseif x == 3 then
    P3D.Parent = dv
    P2D.Parent = dv
    P1D.Parent = dv
    P3T.Parent = pt
    P2T.Parent = pt
    P1T.Parent = pt
    Name1.Parent = pn
    Name2.Parent = pn
    Name3.Parent = pn
elseif x == 2 then
    P2D.Parent = dv
    P1D.Parent = dv
    P2T.Parent = pt
    P1T.Parent = pt
    Name1.Parent = pn
    Name2.Parent = pn
elseif x == 1 then
    P1D.Parent = dv
    P1T.Parent = pt
    Name1.Parent = pn
end


end

Answer this question