Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to combine these two Scripts?

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

✓ Accepted answer

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)

2 comments

1

Dude your a legend!!!! thanks!

0

Thanks :)

This discussion is preserved as it was. New answers, comments, and votes are closed.