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

When it copys to my inventory it copys 100 items?

Asked by 9 years ago
gui = script.Parent.Parent
Player = script.Parent.Parent.Parent.Parent.Touch.NameValue
Sandwich = game.Lighting:FindFirstChild("Ham Sandwich")
script.Parent.MouseButton1Down:connect(function()
game.Workspace.Sandwich.Ham.Transparency = 0
for i = 1,36 do
script.Parent.Parent.Parent.Parent.ClickBlock.CFrame  = script.Parent.Parent.Parent.Parent.ClickBlock.CFrame-Vector3.new(0,-0.500,0)
wait(0.033)
game.Workspace.Sandwich.Ham.Transparency = 1
for _,gui in pairs(gui:GetChildren()) do
gui.Visible = false
local f = Sandwich:Clone()
f.Parent = game.Players:FindFirstChild(Player.Value).Backpack
end
end
end)

Thats the code

1 answer

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

This is a fairly simple problem.

First of all, indent your code properly! Every statement that requires an end increases the indentation by one layer:

gui = script.Parent.Parent
Player = script.Parent.Parent.Parent.Parent.Touch.NameValue
Sandwich = game.Lighting:FindFirstChild("Ham Sandwich")

script.Parent.MouseButton1Down:connect(function()
    game.Workspace.Sandwich.Ham.Transparency = 0
    for i = 1,36 do
        script.Parent.Parent.Parent.Parent.ClickBlock.CFrame  = script.Parent.Parent.Parent.Parent.ClickBlock.CFrame-Vector3.new(0,-0.500,0)
        wait(0.033)
        game.Workspace.Sandwich.Ham.Transparency = 1
        for _,gui in pairs(gui:GetChildren()) do
            gui.Visible = false
            local f = Sandwich:Clone()
            f.Parent = game.Players:FindFirstChild(Player.Value).Backpack
        end
    end
end)

Now, it's obvious that the code giving you the tool is inside of two loops. None of that code should be nested:

gui = script.Parent.Parent
Player = script.Parent.Parent.Parent.Parent.Touch.NameValue
Sandwich = game.Lighting:FindFirstChild("Ham Sandwich")

script.Parent.MouseButton1Down:connect(function()
    game.Workspace.Sandwich.Ham.Transparency = 0
    for i = 1,36 do
        script.Parent.Parent.Parent.Parent.ClickBlock.CFrame  = script.Parent.Parent.Parent.Parent.ClickBlock.CFrame-Vector3.new(0,-0.500,0)
        wait(0.033)
    end

    game.Workspace.Sandwich.Ham.Transparency = 1
    for _,gui in pairs(gui:GetChildren()) do
        gui.Visible = false
    end

    local f = Sandwich:Clone()
    f.Parent = game.Players:FindFirstChild(Player.Value).Backpack
end)
1
You could have made an awesome pun here you know, "I think you just got LostInCode because of not tabbing" YellowoTide 1992 — 9y
0
no adark 5487 — 9y
Ad

Answer this question