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

To many upvalues error, how to simplify?

Asked by 4 years ago

Ik this code is terrible. And I could probably make this in just 20 lines. Could anyone help me make it have less code to solve the problem?


local blockbreak = game.ReplicatedStorage.Blockbreakstage local bk11 = blockbreak.Destroy1["1destroy"]:Clone() local bk12 = blockbreak.Destroy1["2destroy"]:Clone() local bk13 = blockbreak.Destroy1["3destroy"]:Clone() local bk14 = blockbreak.Destroy1["4destroy"]:Clone() local bk15 = blockbreak.Destroy1["5destroy"]:Clone() local bk16 = blockbreak.Destroy1["6destroy"]:Clone() local bk21 = blockbreak.Destroy2["1destroy"]:Clone() local bk22 = blockbreak.Destroy2["2destroy"]:Clone() local bk23 = blockbreak.Destroy2["3destroy"]:Clone() local bk24 = blockbreak.Destroy2["4destroy"]:Clone() local bk25 = blockbreak.Destroy2["5destroy"]:Clone() local bk26 = blockbreak.Destroy2["6destroy"]:Clone() local bk31 = blockbreak.Destroy3["1destroy"]:Clone() local bk32 = blockbreak.Destroy3["2destroy"]:Clone() local bk33 = blockbreak.Destroy3["3destroy"]:Clone() local bk34 = blockbreak.Destroy3["4destroy"]:Clone() local bk35 = blockbreak.Destroy3["5destroy"]:Clone() local bk36 = blockbreak.Destroy3["6destroy"]:Clone() local bk41 = blockbreak.Destroy4["1destroy"]:Clone() local bk42 = blockbreak.Destroy4["2destroy"]:Clone() local bk43 = blockbreak.Destroy4["3destroy"]:Clone() local bk44 = blockbreak.Destroy4["4destroy"]:Clone() local bk45 = blockbreak.Destroy4["5destroy"]:Clone() local bk46 = blockbreak.Destroy4["6destroy"]:Clone() local bk51 = blockbreak.Destroy5["1destroy"]:Clone() local bk52 = blockbreak.Destroy5["2destroy"]:Clone() local bk53 = blockbreak.Destroy5["3destroy"]:Clone() local bk54 = blockbreak.Destroy5["4destroy"]:Clone() local bk55 = blockbreak.Destroy5["5destroy"]:Clone() local bk56 = blockbreak.Destroy5["6destroy"]:Clone() local bk61 = blockbreak.Destroy6["1destroy"]:Clone() local bk62 = blockbreak.Destroy6["2destroy"]:Clone() local bk63 = blockbreak.Destroy6["3destroy"]:Clone() local bk64 = blockbreak.Destroy6["4destroy"]:Clone() local bk65 = blockbreak.Destroy6["5destroy"]:Clone() local bk66 = blockbreak.Destroy6["6destroy"]:Clone() local bk71 = blockbreak.Destroy7["1destroy"]:Clone() local bk72 = blockbreak.Destroy7["2destroy"]:Clone() local bk73 = blockbreak.Destroy7["3destroy"]:Clone() local bk74 = blockbreak.Destroy7["4destroy"]:Clone() local bk75 = blockbreak.Destroy7["5destroy"]:Clone() local bk76 = blockbreak.Destroy7["6destroy"]:Clone() local bk81 = blockbreak.Destroy8["1destroy"]:Clone() local bk82 = blockbreak.Destroy8["2destroy"]:Clone() local bk83 = blockbreak.Destroy8["3destroy"]:Clone() local bk84 = blockbreak.Destroy8["4destroy"]:Clone() local bk85 = blockbreak.Destroy8["5destroy"]:Clone() local bk86 = blockbreak.Destroy8["6destroy"]:Clone() local bk91 = blockbreak.Destroy9["1destroy"]:Clone() local bk92 = blockbreak.Destroy9["2destroy"]:Clone() local bk93 = blockbreak.Destroy9["3destroy"]:Clone() local bk94 = blockbreak.Destroy9["4destroy"]:Clone() local bk95 = blockbreak.Destroy9["5destroy"]:Clone() local bk96 = blockbreak.Destroy9["6destroy"]:Clone() local bk101 = blockbreak.Destroy10["1destroy"]:Clone() local bk102 = blockbreak.Destroy10["2destroy"]:Clone() local bk103 = blockbreak.Destroy10["3destroy"]:Clone() local bk104 = blockbreak.Destroy10["4destroy"]:Clone() local bk105 = blockbreak.Destroy10["5destroy"]:Clone() local bk106 = blockbreak.Destroy10["6destroy"]:Clone() mouse.Button1Down:Connect(function() bk11.Parent = target bk12.Parent = target bk13.Parent = target bk14.Parent = target bk15.Parent = target bk16.Parent = target wait(waitspeed) bk11:Destroy() bk12:Destroy() bk13:Destroy() bk14:Destroy() bk15:Destroy() bk16:Destroy() bk21.Parent = target bk22.Parent = target bk23.Parent = target bk24.Parent = target bk25.Parent = target bk26.Parent = target wait(waitspeed) bk21:Destroy() bk22:Destroy() bk23:Destroy() bk24:Destroy() bk25:Destroy() bk26:Destroy() bk31.Parent = target bk32.Parent = target bk33.Parent = target bk34.Parent = target bk35.Parent = target bk36.Parent = target wait(waitspeed) bk31:Destroy() bk32:Destroy() bk33:Destroy() bk34:Destroy() bk35:Destroy() bk36:Destroy() bk41.Parent = target bk42.Parent = target bk43.Parent = target bk44.Parent = target bk45.Parent = target bk46.Parent = target wait(waitspeed) bk41:Destroy() bk42:Destroy() bk43:Destroy() bk44:Destroy() bk45:Destroy() bk46:Destroy() bk51.Parent = target bk52.Parent = target bk53.Parent = target bk54.Parent = target bk55.Parent = target bk56.Parent = target wait(waitspeed) bk51:Destroy() bk52:Destroy() bk53:Destroy() bk54:Destroy() bk55:Destroy() bk56:Destroy() bk61.Parent = target bk62.Parent = target bk63.Parent = target bk64.Parent = target bk65.Parent = target bk66.Parent = target wait(waitspeed) bk61:Destroy() bk62:Destroy() bk63:Destroy() bk64:Destroy() bk65:Destroy() bk66:Destroy() bk71.Parent = target bk72.Parent = target bk73.Parent = target bk74.Parent = target bk75.Parent = target bk76.Parent = target wait(waitspeed) bk71:Destroy() bk72:Destroy() bk73:Destroy() bk74:Destroy() bk75:Destroy() bk76:Destroy() bk81.Parent = target bk82.Parent = target bk83.Parent = target bk84.Parent = target bk85.Parent = target bk86.Parent = target wait(waitspeed) bk81:Destroy() bk82:Destroy() bk83:Destroy() bk84:Destroy() bk85:Destroy() bk86:Destroy() bk91.Parent = target bk92.Parent = target bk93.Parent = target bk94.Parent = target bk95.Parent = target bk96.Parent = target wait(waitspeed) bk91:Destroy() bk92:Destroy() bk93:Destroy() bk94:Destroy() bk95:Destroy() bk96:Destroy() bk101.Parent = target bk102.Parent = target bk103.Parent = target bk104.Parent = target bk105.Parent = target bk106.Parent = target wait(waitspeed) bk101:Destroy() bk102:Destroy() bk103:Destroy() bk104:Destroy() bk105:Destroy() bk106:Destroy()
0
For loops, tables. Sonnenroboter 336 — 4y
0
Why tables programmerHere 371 — 4y

1 answer

Log in to vote
3
Answered by 4 years ago

What is an upvalue

An upvalue is an external local variable; a local variable used in a function body but declared outside of it. I believe the maximum amount of upvalues is about 60. You have waaaayyyy too many variables here. And yes, your code can severely be simplified.

Loops

Use loops! This will shorten and simplify your code.

This code works. Make sure you put it inside the event listener.

for i = 1, 10 do
    local current_destroy = blockbreak["Destroy" .. i]

    for j = 1, 6 do
        local current_bk = current_destroy[j .. "destroy"]:Clone()
        current_bk.Parent = target
        wait(waitspeed)
        current_bk:Destroy()
    end
end
0
Really good awsner. Helped be a lot! Skydoeskey 108 — 4y
1
-1 for not giving wiki link Robowon1 323 — 4y
0
You need mental help, there is no wiki link on upvalues and their explanations are like worst programmerHere 371 — 4y
Ad

Answer this question