Here is my code, it worked while there was only one if statement.
local debounce = false script.Parent.Button.ClickDetector.MouseClick:connect(function(onClick) if debounce == false then debounce = true end if workspace.ButtonBooleans.isBought.Value == false then local part = Instance.new("Part") part.Position = script.Parent.PrimaryPart.Position part.Size = Vector3.new(1, 1, 1) part.Material = Enum.Material.CorrodedMetal --material code = 1040 part.Name = "RustMetal" part.Parent = script.Parent part.Color = Color3.new("Dark stone grey") wait(0.5) debounce = false wait(6) local Player = game.Players.LocalPlayer Player:WaitForChild("leaderstats").Money.Value = Player:WaitForChild("leaderstats").Money.Value + 1 else if workspace.ButtonBooleans.isBought.Value == true then script.Parent:WaitForChild("Duplicator") local part = Instance.new("Part") part.Position = script.Parent.PrimaryPart.Position part.Size = Vector3.new(1, 1, 1) part.Material = Enum.Material.CorrodedMetal --material code = 1040 part.Name = "RustMetal" part.Parent = script.Parent part.Color = Color3.new("Dark stone grey") local Dpart = Instance.new("Part") Dpart.Parent = script.Parent Dpart.Position = script.Parent.Duplicator.PrimaryPart.Position Dpart.Size = Vector3.new(1, 1, 1) Dpart.Material = Enum.Material.CorrodedMetal -- material code = 1040 Dpart.Name = "RustMetal" Dpart.Color = Color3.new("Dark stone grey") wait(0.5) debounce = false wait(6) local Player = game.Players.LocalPlayer Player:WaitForChild("leaderstats").Money.Value = Player:WaitForChild("leaderstats").Money.Value + 2 end end end)
The problem was when you made you Debounce if statement you added a end right after it which meant the Debounce basically stoped right after you created the if statement this caused it to not take effect.
local debounce = false script.Parent.Button.ClickDetector.MouseClick:connect(function(onClick) if debounce == false then debounce = true if workspace.ButtonBooleans.isBought.Value == false then local part = Instance.new("Part") part.Position = script.Parent.PrimaryPart.Position part.Size = Vector3.new(1, 1, 1) part.Material = Enum.Material.CorrodedMetal --material code = 1040 part.Name = "RustMetal" part.Parent = script.Parent part.Color = Color3.new("Dark stone grey") wait(0.5) debounce = false wait(6) local Player = game.Players.LocalPlayer Player:WaitForChild("leaderstats").Money.Value = Player:WaitForChild("leaderstats").Money.Value + 1 else if workspace.ButtonBooleans.isBought.Value == true then script.Parent:WaitForChild("Duplicator") local part = Instance.new("Part") part.Position = script.Parent.PrimaryPart.Position part.Size = Vector3.new(1, 1, 1) part.Material = Enum.Material.CorrodedMetal --material code = 1040 part.Name = "RustMetal" part.Parent = script.Parent part.Color = Color3.new("Dark stone grey") local Dpart = Instance.new("Part") Dpart.Parent = script.Parent Dpart.Position = script.Parent.Duplicator.PrimaryPart.Position Dpart.Size = Vector3.new(1, 1, 1) Dpart.Material = Enum.Material.CorrodedMetal -- material code = 1040 Dpart.Name = "RustMetal" Dpart.Color = Color3.new("Dark stone grey") wait(0.5) debounce = false wait(6) local Player = game.Players.LocalPlayer Player:WaitForChild("leaderstats").Money.Value = Player:WaitForChild("leaderstats").Money.Value + 2 end--Here is where you if statement end should of been. end end end)