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

How to combine these two Scripts?

Asked by 3 years ago

I have this code

local plr = game:GetService('Players').LocalPlayer
    local backpack = plr:WaitForChild("Backpack")

    for i, v in pairs(backpack:GetChildren()) do
        if v:IsA("Tool") then
            v:Destroy()
        end
    end

that was given to me by ColdFoxy07(big thanks) and I have This code that I edited

local cooldown = false --//r
    local button = script.Parent
    local plr = game:GetService('Players').LocalPlayer
    local tool = game.ReplicatedStorage.ACS_Engine.HOOD["Micro UZI"]

    button.Activated:Connect(function()
        if cooldown == false then
            cooldown = true
        script.Parent.Parent.Visible = false
        plr.Backpack:FindFirstChildWhichIsA('Tool'):Destroy()
        local clone = tool
        clone.Parent = plr.Backpack
        wait(0.5)
        script.Parent.Parent.Parent.ClassH.Visible = true
        wait(3)
            script.Parent.Parent.Parent.ClassH.Visible = false
            cooldown = false
            end
        end)

and Im trying to put the two together. but it doesent work here is the code( that I made trying to put the two together)

local cooldown = false --//r
    local button = script.Parent
    local plr = game:GetService('Players').LocalPlayer
    local tool = game.ReplicatedStorage.ACS_Engine.HOOD["Micro UZI"]
local backpack = plr:WaitForChild("Backpack")

    button.Activated:Connect(function()
        if cooldown == false then
            cooldown = true
        script.Parent.Parent.Visible = false
     for i, v in pairs(backpack:GetChildren()) do
        if v:IsA("Tool") then
            v:Destroy()
        local clone = tool
        clone.Parent = plr.Backpack
        wait(0.5)
        script.Parent.Parent.Parent.ClassH.Visible = true
        wait(3)
            script.Parent.Parent.Parent.ClassH.Visible = false
            cooldown = false
end
            end
        end)

Could anyone help thanks!

1 answer

Log in to vote
0
Answered by 3 years ago

Hey again! Hopefully I fixed it for you;

local cooldown = false --//r
    local button = script.Parent
    local plr = game:GetService('Players').LocalPlayer
    local tool = game.ReplicatedStorage.ACS_Engine.HOOD["Micro UZI"]
    local backpack = plr:WaitForChild("Backpack")


    button.Activated:Connect(function()
        if cooldown == false then
            cooldown = true
        script.Parent.Parent.Visible = false
        for i, v in pairs(backpack:GetChildren()) do
        if v:IsA("Tool") then
            v:Destroy()
        end
    end
        local clone = tool
        clone.Parent = plr.Backpack
        wait(0.5)
        script.Parent.Parent.Parent.ClassH.Visible = true
        wait(3)
            script.Parent.Parent.Parent.ClassH.Visible = false
            cooldown = false
            end
        end)

1
Dude your a legend!!!! thanks! Iownrobloxp 44 — 3y
0
Thanks :) ColdFoxy07 76 — 3y
Ad

Answer this question