Elseif doesnt work

I am making one inventory system and when the backpack got +3 tools then this will happen:

classic.MouseButton1Click:Connect(function()
	selected = "classic"
	if tool1Equipped == false then
		equip.Text = "Equip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
		ToolNameText.Text = "Tool: "..tool1.Name
		ToolDescp.Text = "Description: Classic Roblox sword"
	elseif limit >= 1 then
		equip.Text = "backpack full!"
	else 
		equip.Text = "Unequip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		ToolNameText.Text = "Tool: "..tool1.Name
		ToolDescp.Text = "Description: Classic Roblox sword"
	end
end)

But for someresson doesnt work.

Gif:

The fist button I cliked was the button for change the equip.Text

I’m not sure where these variables are coming from…?

image

I will show you the full script:

local player = game.Players.LocalPlayer
local RS = game:GetService("ReplicatedStorage")
local leaderstats = player:WaitForChild("toolLeaderstats")
local toolsRS = RS.Tools
local scrollFrameMelee = script.Parent.Parent.Meeles
local scrollFrameGuns = script.Parent.Parent.Guns

--------Tool Buttons ------
local classic = scrollFrameMelee.ClassicSwordButton
local classicBomb = scrollFrameMelee.ClassicBombButton
local Bagguete = scrollFrameMelee.BaggueteSwordButton
local BanH = scrollFrameMelee.BanHammerButton
local StopSign = scrollFrameMelee.StopSignButton
local Bat = scrollFrameMelee.BatButton
local LondonKnife = scrollFrameMelee.LondonKnifeButton
local FryingPan = scrollFrameMelee.FryingPanButton

local equip = script.Parent.ToolButton
local ToolNameText = script.Parent.ToolName
local ToolDescp = script.Parent.ToolDescription
local ToolImage = script.Parent.ToolImage
local selected = nil
-------- var for equip-----
local tool1Equipped = false
local tool2Equipped = false
local tool3Equipped = false
local tool4Equipped = false
local tool5Equipped = false
local tool6Equipped = false
local tool7Equipped = false
local tool8Equipped = false
---------RS tools-----------
local tool1 = toolsRS.ClassicSword
local tool2 = toolsRS.ClassicBomb
local tool3 = toolsRS.BaggueteSword
local tool4 = toolsRS.BanHammer
local tool5 = toolsRS.StopSign
local tool6 = toolsRS.Bat
local tool7 = toolsRS.LondonKnife
local tool8 = toolsRS.FryingPan
---------------------------
-- Equip button---
limit = 1

local test = false
equip.MouseButton1Click:Connect(function()
	if selected == "classic" then
		if tool1Equipped == false then
			tool1Equipped = true
			tool1:Clone().Parent = player.Backpack
			RS.ToolsCloneRemoteEvents.ClassicSwordEvent:FireServer("ClassicSword")
			equip.Text = "Unequip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		else
			tool1Equipped = false
			equip.Text = "Equip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
			player.Backpack:FindFirstChild("ClassicSword"):Destroy()
			player.StarterGear:FindFirstChild("ClassicSword"):Destroy()
		end
	end
end)


equip.MouseButton1Click:Connect(function()
	if selected == "classicBomb" then
		if tool2Equipped == false then
			tool2Equipped = true
			limit = limit - 1
			print(limit)
			tool2:Clone().Parent = player.Backpack
			RS.ToolsCloneRemoteEvents.ClassicBombEvent:FireServer("ClassicBomb")
			equip.Text = "Unequip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		else
			tool2Equipped = false
			equip.Text = "Equip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
			player.Backpack:FindFirstChild("ClassicBomb"):Destroy()
			player.StarterGear:FindFirstChild("ClassicBomb"):Destroy()
		end
	end
end)

equip.MouseButton1Click:Connect(function()
	if selected == "Bagguete" then
		if tool3Equipped == false then
			tool3Equipped = true
			limit = limit + 1
			print(limit)
			tool3:Clone().Parent = player.Backpack
			RS.ToolsCloneRemoteEvents.BaggueteSwordEvent:FireServer("BaggueteSword")
			equip.Text = "Unequip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		else
			tool3Equipped = false
			equip.Text = "Equip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
			player.Backpack:FindFirstChild("BaggueteSword"):Destroy()
			player.StarterGear:FindFirstChild("BaggueteSword"):Destroy()
		end
	end
end)

equip.MouseButton1Click:Connect(function()
	if selected == "BanH" then
		if tool4Equipped == false then
			tool4Equipped = true
			limit = limit + 1
			print(limit)
			tool4:Clone().Parent = player.Backpack
			RS.ToolsCloneRemoteEvents.BanHammerEvent:FireServer("BanHammer")
			equip.Text = "Unequip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		else
			tool4Equipped = false
			equip.Text = "Equip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
			player.Backpack:FindFirstChild("BanHammer"):Destroy()
			player.StarterGear:FindFirstChild("BanHammer"):Destroy()
		end
	end
end)

equip.MouseButton1Click:Connect(function()
	if selected == "StopSign" then
		if tool5Equipped == false then
			tool5Equipped = true
			tool5:Clone().Parent = player.Backpack
			RS.ToolsCloneRemoteEvents.StopSignEvent:FireServer("StopSign")
			equip.Text = "Unequip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		else
			tool5Equipped = false
			equip.Text = "Equip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
			player.Backpack:FindFirstChild("StopSign"):Destroy()
			player.StarterGear:FindFirstChild("StopSign"):Destroy()
		end
	end
end)

equip.MouseButton1Click:Connect(function()
	if selected == "Bat" then
		if tool6Equipped == false then
			tool6Equipped = true
			tool6:Clone().Parent = player.Backpack
			RS.ToolsCloneRemoteEvents.BatEvent:FireServer("Bat")
			equip.Text = "Unequip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		else
			tool6Equipped = false
			equip.Text = "Equip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
			player.Backpack:FindFirstChild("Bat"):Destroy()
			player.StarterGear:FindFirstChild("Bat"):Destroy()
		end
	end
end)

equip.MouseButton1Click:Connect(function()
	if selected == "LondonKnife" then
		if tool7Equipped == false then
			tool7Equipped = true
			tool7:Clone().Parent = player.Backpack
			RS.ToolsCloneRemoteEvents.LondonKnifeEvent:FireServer("LondonKnife")
			equip.Text = "Unequip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		else
			tool7Equipped = false
			equip.Text = "Equip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
			player.Backpack:FindFirstChild("LondonKnife"):Destroy()
			player.StarterGear:FindFirstChild("LondonKnife"):Destroy()
		end
	end
end)

equip.MouseButton1Click:Connect(function()
	if selected == "FryingPan" then
		if tool8Equipped == false then
			tool8Equipped = true
			tool8:Clone().Parent = player.Backpack
			RS.ToolsCloneRemoteEvents.FryingPanEvent:FireServer("FryingPan")
			equip.Text = "Unequip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		else
			tool8Equipped = false
			equip.Text = "Equip weapon" 
			equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
			player.Backpack:FindFirstChild("FryingPan"):Destroy()
			player.StarterGear:FindFirstChild("FryingPan"):Destroy()
		end
	end
end)
-- Change Buttons --
print(limit)
classic.MouseButton1Click:Connect(function()
	selected = "classic"
	if tool1Equipped == false then
		equip.Text = "Equip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
		ToolNameText.Text = "Tool: "..tool1.Name
		ToolDescp.Text = "Description: Classic Roblox sword"
	elseif limit >= 1 then
		equip.Text = "backpack full!"
	else 
		equip.Text = "Unequip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		ToolNameText.Text = "Tool: "..tool1.Name
		ToolDescp.Text = "Description: Classic Roblox sword"
	end
end)

classicBomb.MouseButton1Click:Connect(function()
	selected = "classicBomb"
	if tool2Equipped == false then
		equip.Text = "Equip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
		ToolNameText.Text = "Tool: "..tool2.Name
		ToolDescp.Text = "Description: Roblox ClassicBomb"
	else
		equip.Text = "Unequip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		ToolNameText.Text = "Tool: "..tool2.Name
		ToolDescp.Text = "Description: Roblox ClassicBomb"
	end
end)

Bagguete.MouseButton1Click:Connect(function()
	selected = "Bagguete"
	if tool3Equipped == false then
		equip.Text = "Equip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
		ToolNameText.Text = "Tool: "..tool3.Name
		ToolDescp.Text = "Description: OUI OUI BAGGUETE"
	else
		equip.Text = "Unequip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		ToolNameText.Text = "Tool: "..tool3.Name
		ToolDescp.Text = "Description: OUI OUI BAGGUETE"
	end
end)

BanH.MouseButton1Click:Connect(function()
	selected = "BanH"
	if tool4Equipped == false then
		equip.Text = "Equip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
		ToolNameText.Text = "Tool: "..tool4.Name
		ToolDescp.Text = "Description: Get banned xd"
	else
		equip.Text = "Unequip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		ToolNameText.Text = "Tool: "..tool4.Name
		ToolDescp.Text = "Description: Get banned xd"
	end
end)

StopSign.MouseButton1Click:Connect(function()
	selected = "StopSign"
	if tool5Equipped == false then
		equip.Text = "Equip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
		ToolNameText.Text = "Tool: "..tool5.Name
		ToolDescp.Text = "Description: S T O P"
	else
		equip.Text = "Unequip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		ToolNameText.Text = "Tool: "..tool5.Name
		ToolDescp.Text = "Description: S T O P"
	end
end)

Bat.MouseButton1Click:Connect(function()
	selected = "Bat"
	if tool6Equipped == false then
		equip.Text = "Equip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
		ToolNameText.Text = "Tool: "..tool6.Name
		ToolDescp.Text = "Description: BONK!"
	else
		equip.Text = "Unequip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		ToolNameText.Text = "Tool: "..tool6.Name
		ToolDescp.Text = "Description: BONK!"
	end
end)

LondonKnife.MouseButton1Click:Connect(function()
	selected = "LondonKnife"
	if tool7Equipped == false then
		equip.Text = "Equip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
		ToolNameText.Text = "Tool: "..tool7.Name
		ToolDescp.Text = "Description: London."
	else
		equip.Text = "Unequip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		ToolNameText.Text = "Tool: "..tool7.Name
		ToolDescp.Text = "Description: London."
	end
end)

FryingPan.MouseButton1Click:Connect(function()
	selected = "FryingPan"
	if tool8Equipped == false then
		equip.Text = "Equip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
		ToolNameText.Text = "Tool: "..tool8.Name
		ToolDescp.Text = "Description: Cool for make eggs and bacon."
	else
		equip.Text = "Unequip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		ToolNameText.Text = "Tool: "..tool8.Name
		ToolDescp.Text = "Description: Cool for make eggs and bacon."
	end
end)

Basicly I am using that for unequip and equip weapons but I cant do elseif on it bc if I do that. I will equip the weapon first and I dont want to do that. so I change the button when I click.

classic.MouseButton1Click:Connect(function()
	selected = "classic"
	if not limit >= 1 then
	if tool1Equipped == false then
		equip.Text = "Equip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(0, 170, 0)
		ToolNameText.Text = "Tool: "..tool1.Name
		ToolDescp.Text = "Description: Classic Roblox sword"
	else 
		equip.Text = "Unequip weapon" 
		equip.BackgroundColor3 = Color3.fromRGB(170, 0, 0)
		ToolNameText.Text = "Tool: "..tool1.Name
		ToolDescp.Text = "Description: Classic Roblox sword"
	end
	else
		equip.Text = "backpack full!"
	end
end)

Try this maybe?


image

Change line:

if not limit >= 1 then

To

if limit == 0 then

Ok it works now I will try to make it for not equip weapons (basicly I will try to change tool1Equipped to true I guess will works)

Alright good luck.(characters)

how I can make it nil like, Cant equip and cant do nothing while limit == 0


I still can use it normal.